Greetings all,
I am, obviously, new to Java. I am in my second Java class at UOP, and quite honestly, they seem to believe in letting us teach ourselves! Enough of my rant.
I am currently working on expanding a mortgage calculator program, such that it needs to open a .txt file (I assume), and fill an array with 'double' values to be used as interest rates. I currently have a .txt file named "rates.txt" residing in the same folder as my .java. What I have compiles just fine, but when it is executed, it returns "0.0" for all seven interest rates in the JComboBox. I am thinking that maybe I missed a line of code in the transfer of data, failed to open the file, or am just all messed up! One of my fellow students already pointed out that part of my problem is passing a String to a Double. I thought that when a .txt file was opened, it was read out as a String, then needed to be converted to Double. Hopefully someone can give me some guidance here. Not looking for give-me's, just some pointers.
Below is the portion of code that I intended to accomplish this transfer, let me know if you need more.
public void mortCalc() {
try {
int j = 0;
String temp = "";
BufferedReader in = new BufferedReader(new FileReader("rate.txt"));
while((temp = in.readLine()) != null) {
rate[j] = Double.parseDouble(temp.trim());
j++;
}
in.close();
}
catch (Exception E) {
}