How to display an double type variable's value with two decimals?

for exmple, what I do is:
double a = 1.5;
system.out.println(a);
I see 1.5 in the screen, however, I wanna display 1.50. how to do that?
I know how to round an double value, say, 1.555 to 1.56, but I can't find how to display a double value from one decimal to two decimal, any help will be very appreciate!

for exmple, what I do is:
double a = 1.5;
system.out.println(a);
I see 1.5 in the screen, however, I wanna display
1.50. how to do that?
you could convert the double to a string and then append a zero to the end
String str = Double.toString(a);
str += "0";
System.out.println(a);

Similar Messages

  • How to display a double page of a magazine with ibooks

    how to display a double page of a magazine with ibooks ?
    Thanks

    oiram osurac wrote:
    how to display a double page of a magazine with ibooks ?
    What is the title of the magazine you are talking about?

  • Java and a double type variable

    Hello.
    I?m having problems with double type variables.
    code:
    public class Java{
    public static void main(String[] args){
    double s =0.00;
    for(int i=0; i<10; i++){
    s+=0.01;
    System.out.println(s);
    it prints the following
    0.01
    0.02
    0.03
    0.04
    0.05
    0.060000000000000005
    0.07
    0.08
    0.09
    0.09999999999999999
    dont get it why 0.05+0.01 = 0.060000000000000005 ?

    hightech wrote:
    is bug!?!!?!to the original poster, this answer is not only incorrect but it is quite possibly deliberately misleading from a known forum troll. Please ignore it.

  • How to set a date type variable to null, nothing or such

    I created an User Defined Type that holds a Deadline property which is date type. Whenever there is no Deadline set yet, I would like such property to be set to Null, Nothing or such. I noticed that if I just Dim a Date Type variable its value will be
    already set to 12:00 AM, and the same value takes place if I set the variable to a blank cell value. Any ideas to get around of this problem?
    Jorge Barbi Martins ([email protected])

    A variable of type Date cannot be empty. Its default value is 0, which corresponds to Midnight on 30 December 1899.
    If you want to be able to make it empty, declare it as Variant instead of as Date. You can then set its value to Null.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • How to display the contents of the database values which are retrived.

    how to display the contents of the database values which are retrived in servlets and i am able to display the contents in the servlets and if forward to jsp using requestdespatcher,the values are to be shown in jsp one below the other.please suggest me in these........the servlet code is as shown
    while(rs.next()){
                        buffer.append(rs.getString(1));
                        buffer.append(rs.getString(2));
                        buffer.append(rs.getString(3));
                        buffer.append(rs.getString(4));
                        buffer.append(rs.getString(5));
                        buffer.append(rs.getString(6));
                        buffer.append(rs.getString(7));
                        buffer.append(rs.getString(8));
                        buffer.append(rs.getString(9));
                        buffer.append(rs.getString(10));
                        request.setAttribute("result1",buffer);
                        RequestDispatcher rq=request.getRequestDispatcher("/results.jsp");
                        rq.forward(request,response);
    in jsp iam using the getAttribute to retrieve the values as shown
    <% StringBuffer sb=(StringBuffer)request.getAttribute("result1"); %>
    <%= sb %>
    but getting the results in the stretch,i need to display the result one below the other.

    if you load it all into the buffer that is going to be very difficult. I would suggest loading it into some sort of collection. I like using an ArrayList.
    Then pass the arraylist.
    you will then on the jsp iterate through the arrayList using what every you want.. el, logic tags, scriplets.
    so something like
    ArrayList arrayList = new ArrayList();
    while(rs.next()){
    arrayList.append(rs.getString(1));
    //or possibly an arrayList of String arrays
    //maybe using nested for loops.  Inner for loop adds result to string[] then //outer adds string[] to arrayList.
    //can be done any number of ways based on your expected result set.

  • Value "JCO CALLS" for variable "E2E Metric Type Variable(multiple values)"

    Hello Experts, 
    Workload analysis for java components doesnot show any data.
    more over get "JCO CALLS" for variable "E2E Metric Type Variable(multiple values)"  error.
    my setup wizard completed without any error.
    Any suggestions ?
    Thanks & Regards
    Sankar

    Hi Sankar,
    have a look at my post in no data for Jco in E2E thread.
    Hope this helps.
    Regards,
    Shyam

  • How can i pay on the apple store online with two credit cards, with two different billing addresses

    I will be greatful if you could answer me this question...
    How can i pay on the apple store online with two credit cards, with two different billing addresses?
    I know that you can use two credit cards to pay an item but the problem is that i can only put the billing address of just one of the credit cards, and since the two cards are from different people (my parents) i can't do it. They live in the same place so i don't know if i should just put one of the billing address.
    Thank you.
    PS. I don't know if this is the right community to ask this, sorry if i'm wrong.

    On the Apple Store "Payment & Pricing" page it states:
    Using more than one payment card
    You can also combine payment methods to pay for your purchase. Choose from the following combinations of credit cards and Apple Gift Cards:
    Credit card(s) - up to two
    Apple Gift Card(s) - up to eight
    Apple Gift Card(s) + one credit card
    During checkout, if you are paying with a gift card issued by a credit card company, you can combine it with one credit card.

  • How to find out the type of the value stored in a string variable?

    Hi,
    How do i find out the type of the value stored in a string variable?
    for example,
    I have a string variable str, in which the following type of values wil be stored
    1) Intger
    2) Long
    3) boolean
    4) Char
    Is there any method to find out the type of the value, anything like str.getType()?. Please kindly help me. Thanks in advance.

    Hi All, i'm sorry for the double posting, by mistake it occured.
    Thanks for your replies, i have a string variable str, in which the value is stored and i have another string variable type, in which the type of the value is stored.
    For example,
    String str = "15";
    String type = "Integer";
    Is there any way to verify whether the value stroed in str is of type stored in the variable 'type'. I want to write a method of type boolean, it will throw true of the value stored in str is of type 'type'. Thanks

  • How to Populate a table type variable from a cursor

    Hi
    I have a stored procedure (P1) that returns a ref cursor as the output.
    Another procedure (P2) receives this ref cursor (C).
    In this procedure (P2), I want to do a Bulk Collect from this ref cursor (C) in
    a table type variable that has been declared locally in the procedure P2. I have created appropriate Object Type and Table Types at the database level.
    Please advise how to do it. I tried to do it in different ways, but was not able to do it - each time I faced incompatible data-type related issues.
    Regards
    Madhup

    What I wrote was unclear. Syntactically it is valid and does something. But consider the advantage of a decent design.
    SQL> create or replace procedure p1 (o out sys_refcursor) as
      2  begin
      3   open o for select * from emp;
      4  end p1;
      5  /
    Procedure created.
    SQL> create or replace procedure p2(i sys_refcursor) as
      2   type emp_tab is table of emp%rowtype;
      3   l_emp_tab emp_tab;
      4  begin
      5   fetch i bulk collect into l_emp_tab;
      6   close i;
      7  
      8   for i in 1..l_emp_tab.count loop
      9     NULL;
    10   end loop;
    11  end p2;
    12  /
    Procedure created.
    SQL> CREATE OR REPLACE PROCEDURE p3 IS
      2 
      3  TYPE myarray IS TABLE OF emp%ROWTYPE;
      4  l_data myarray;
      5 
      6  CURSOR r IS
      7  SELECT * FROM emp;
      8 
      9  BEGIN
    10    OPEN r;
    11    LOOP
    12      FETCH r BULK COLLECT INTO l_data;
    13 
    14      FOR j IN 1 .. l_data.COUNT
    15      LOOP
    16        NULL;
    17      END LOOP;
    18 
    19      EXIT WHEN r%NOTFOUND;
    20    END LOOP;
    21    CLOSE r;
    22  END p3;
    23  /
    Procedure created.
    SQL> set serverout on
    SQL> set timing on
    SQL> declare
      2   r sys_refcursor;
      3  begin
      4    FOR i IN 1 .. 10000 LOOP
      5      p1(r);
      6      p2(r);
      7    END LOOP;
      8  end;
      9  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.71
    SQL> begin
      2    FOR i IN 1 .. 10000 LOOP
      3      p3;
      4    END LOOP;
      5  end;
      6  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:01.21
    SQL> Again sorry for being less than clear.

  • How to insert into table type variables

    hi all,
    how to assingn values to table type variable, i am getting error.
    declare
    dept1 dept%rowtype;
    begin
    dept1:=(100,'SHIPPING','HYDERABAD');
    end;
    ERROR at line 4:
    ORA-06550: line 4, column 8:
    PLS-00382: expression is of wrong type
    regards,
    Sri Ram.

    You can do like this
    declare
      dept1 dept%rowtype;
    begin
      dept1.deptno := 10;
      dept1.dname := 'IT';
    end;
    /

  • How to display HTML formatted text in the field with Item Style: Raw Text

    How can I display HTML formatted text in the field with Item Style: Raw Text.
    Currently the Item Style is Raw Text, but the text is being displayed along with HTML tags without formatting.
    Regards

    Hi,
    Use Item Style formattedText.
    Regards,
    Gyan

  • How to display amount in words for subtotal value?

    Hi All,
    I am diplaying a amount in words for sub-total value after each document number.
    Can any one suggest how to display text for sub-total value not for Grand total?
    I want subtotal at each material for each document number and want to display that subtotal amount in words.
    Thanks and Regards
    Steve

    Thanks Jorge ,
    Is it possible in ALV printing Sut-total text by adding a new line .?
    And where to insert At new or on-chane ?
    Sub-total  calculating automatically not programaticall..
    Regards
    Steve

  • How to change BPS multiplanning area variable selected value

    Hi!
    I have a variable, Drop down list, filld with an exit. Now the variable is filld with values and the value selected last time is marked as selected when application is started. I need to start with the variable unselected or take control over whitch value to have as selected.
    Any sugestions how to do that?
    Edited by: Jan Kihlström on May 29, 2008 8:38 AM
    Edited by: Jan Kihlström on Jun 10, 2008 9:52 AM

    Hi,
    whenever we execute layout second time, it will always show the last saved variable value.
    what can you do in this case, clear the output of the variable exit at the start in the exit itself.

  • How to display the PPT, PDF, XL, DOC files with in the Windows store app?

    Hi,
    I would like to display the PPT, PDF, XL, DOC files with in the Windows store app? is there any controls provided by Microsoft to view these files with in the app?
    Or
    Any workaround to achieve the desired functionality?
    Kindly provide your inputs if any one has.
    Regards
    Prasad

    Hi Prasad,
    As I know currently there is no in-build functionality to display the PPT, XLS or DOC file directly on the Windows Store App, but you can always open these files by
    Launcher class
    However a good news is we can display PDF on Windows Store App by
    Windows.Data.Pdf class, see this for more information:
    https://code.msdn.microsoft.com/windowsapps/PDF-viewer-showcase-sample-39ced1e8/
    --James
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to display swf Files and have a datagrid with paging for javaFX

    is there any example of javaFX which can display swf files or have a datagrid with paging.
    sorry for my bad english and by the way i am new to javaFX
    any help wil be appreciate

    Please, refrain from posting identical messages in several forums. Thanks.
    And I doubt JavaFX can display SWF files (it is a concurrent technology, after all! :-)), unless using some JNI/JNA technology (via JDIC? a long way...).
    Datagrid: it is expected in next version (hopefully), there are some implementations around (look for CRUDfx, for example).

Maybe you are looking for

  • Not able to color different rows with different colors in a column of table

    Hi, I am trying to to display different rows with different colors in a column of the table based on some decode condition. I have gone through the following threads : Can we colour the rows in the column of a table Changing Color of a value in a col

  • Dunning Letters and Customer Statements

    Hi All Our client does not want to send dunning letters and statements on backdated invoices for a particular site or sites. Please any clue on how to go about it? Thanks in advance. Ify

  • Work Flow in HR

    <b>Workflow in HR</b> -- Is Workflow optional in all SAP Versions or is it a must use kind of options in ECC 5.0 and ECC 6.0. Can someone point me to some resources on Workflow Pl Proper answers would be rewarded promptly.

  • Printing a pdf document, which is contained in a XString

    Hi Experts, My problem is simple. I'm getting a pdf document from our archive. From the archive-interface I get this document in a XString. This all happens through a Transaction on a windows-client, connected to the SAP-System via SAP-Logon-Pad. Now

  • How add a watermark to the smartform page

    Hi All, Can anybody give me some pointers, how to add a watermark to the page . I have to display a water image, when the user trying to see print preview. I.e. on certain condition i need to print the water mark on the page . I have uploaded the BMP