oh one more thought is that i tried instead of writing a variable to
the file i just did out.write("test");... this worked fine, but my
variable thing wont work still
>The error message it shows is: "Cannot find symbol method
>write(double), line 24, which is out.write(balance);... and i dont have
>any clue how to fix it so that the double variable "balance" will be
>written back to that file
First, bank is a class, so should be spelled Bank and live in a file
called Bank.java.
Second: I modified your code to :
Scanner balanceScanner = new Scanner(new
File("C:/temp/balance.txt"));
so that I could run it on my machine. You might like to invent some
some shorter-to-type dir names to keep your experiments.
Third System.out is a PrintStream. Its most common methods are
print() and println( ... );
PrintStream has a low level write ( byte ) method for writing raw
bytes to the stream, but that is not what you want to do. You want to
print a double, converting it first to string of characters. You just
used the wrong method.
You could convert the double to String and print it or let print() do
the default conversion.
see http://mindprod.com/applets/converter.html
I am impressed with your use of the static import. That is first time
I have seen a newbie take advantage of it to shorten System.out.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
klub - 27 Oct 2005 12:49 GMT
so i take it i make the converter be double-->string and then it gives:
// to Double dd from float f
dd = new Double(f);
what exactly do i do with that?
p.s. thanks a ton for the help... and about the static import thing i
got that outta the book im using (Java 2 for dummies... which doesnt
explain how to write stuff to files)
Roedy Green - 27 Oct 2005 13:03 GMT
>so i take it i make the converter be double-->string and then it gives:
>// to Double dd from float f
>dd = new Double(f);
>
>what exactly do i do with that?
You are not trying to convert float to double.
You are trying to convert double to String
It is an applet not a static display.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
klub - 27 Oct 2005 12:50 GMT
oops... i meant
// to Double dd from String g
try {
/* best, locale-insensitive*/ dd = new Double(g);
/* or locale-insensitive */ dd = Double.valueOf(g);
} catch (NumberFormatException e){}
for that conversion thing heh musta hit the scroll bar on my mouse or
something
Roedy Green - 27 Oct 2005 13:05 GMT
>// to Double dd from String g
>try {
[quoted text clipped - 3 lines]
>for that conversion thing heh musta hit the scroll bar on my mouse or
>something
you did not mean that either. Double is not the same as double.
You want the code to convert from double to String.
in other words, the top line should say "to String from double"
and you select one of the techniques shown.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
klub - 27 Oct 2005 21:44 GMT
hey thanks dude i finally figured it out using this:
import java.io.*;
class double_to_string {
public static void main (String args[]) throws IOException {
double input = 34.78;
String output = new String();
output = String.valueOf(input);
System.out.println(output);
}
}
Roedy Green - 31 Oct 2005 11:10 GMT
> double input = 34.78;
> String output = new String();
>
> output = String.valueOf(input);
> System.out.println(output);
you can shorten that to:
double input = 34.78d;
String output = String.valueOf(input);
System.out.println(output);
And since println is smart you can collapse that further to:
double input = 34.78d;
System.out.println(input);
or even:
System.out.println(34.78d);

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.