KweLi
Full Member
Posts: 29
|
L8
Nov 8, 2001 21:18:02 GMT -5
Post by KweLi on Nov 8, 2001 21:18:02 GMT -5
if the final price has three or more decimal places do we have to change it to two, or do we just leave it as is? Changing it would seem to make things so much more complicated... eg INPUT apple .15 true 1389 banana .34 true 180 quit OUTPUT Purchases:269.55 Tax:40.4325 Grand Total:309.9825 ?
|
|
|
L8
Nov 8, 2001 21:24:11 GMT -5
Post by magnifiedplaid on Nov 8, 2001 21:24:11 GMT -5
how do you convert a string to a double?
|
|
|
L8
Nov 8, 2001 21:35:03 GMT -5
Post by kermit on Nov 8, 2001 21:35:03 GMT -5
this message might be too late cuz the assignment's due tomorrow morning, but anyways, to Newtype, if you have
if (booleanVariable){ ... }
and the boolean variable doesn't have ==true or ==false after it, java automatically sets that condition being true, and will execute the loop if that boolean is true.
|
|
|
L8
Nov 8, 2001 21:37:10 GMT -5
Post by Brutal_Chicken on Nov 8, 2001 21:37:10 GMT -5
Are you speaking about parsing an input into a double?
double d = Double.parseDouble(in.readLine());
Where "in" has been already declared as the bufferedreader input thingy.
If you wish to make a double as a String do:
String wannabe = Double.toString(d);
Hope that was of help.
|
|
|
L8
Nov 8, 2001 21:41:41 GMT -5
Post by kermit on Nov 8, 2001 21:41:41 GMT -5
converting string to double is outlined in the API booklet. it's in the Double class! if you know how to convert string to integer, it's the same sort of thing.
|
|
|
L8
Nov 8, 2001 21:49:07 GMT -5
Post by bladehunter on Nov 8, 2001 21:49:07 GMT -5
There are many methods of converting an int or double to a string, but it is most convenient to use their respective wrapper classes.
Whoa!! that was too CSC.
|
|