dark_danny
03-28-2009, 04:43 PM
Its not complete but its builds and runs, The code basically is suppose to fetch information of a person, so the person can Update, Pay, Query about their account. The begining part is suppose to get all the accounts in the text files and seperate the data into different arrayfiles
This is the code:
import javax.swing.JOptionPane;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class RuBank {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/ITM200/Group Project/src/clients.txt"));
BufferedWriter out = new BufferedWriter(new FileWriter("C:/ITM200/Group Project/src/transactions.txt"));
int a,c,e = 0;
String b,d,f;
String line = in.readLine();
int n = Integer.parseInt(line.trim());
String [] client = new String[n];
String[] Names = new String[n];
double[] Balances = new double[n];
double[] Rates = new double[n];
int cntr = 0;
while((line = in.readLine()) != null && cntr < n) {
client[cntr] = line.trim();
a = line.indexOf(",");
b = line.substring(0,a);
c = line.indexOf(",",a+1);
d = line.substring(a+1,c);
e = line.indexOf(",",c+1);
f = line.substring(e+1).trim();
Names[cntr] = b;
Balances[cntr] = Double.parseDouble(d);
Rates[cntr] = Double.parseDouble(f);
cntr ++;
}
int ID = GetID("Enter Your Employee ID");
String Name = GetName("Who is the client?");
}
public static int GetID(String prompt) {
String a = JOptionPane.showInputDialog(prompt);
int b = Integer.parseInt(a.trim());
return b;
}
public static String GetName(String prompt) {
String a = JOptionPane.showInputDialog(prompt);
a = (a.trim()).toLowerCase();
return a;
}
}
5
john sears,23400.90,3.4
kelly fan,11567.80,5.15
jane simms,347.45,2.78
tom sly,3452.22,6.0
seth abe,1211.00,3.6
That how it looks like in the text
It builds but when i run it does this:
--------------------Configuration: <Default>--------------------
Exception in thread "main" java.lang.NumberFormatException: For input string: "john sears,23400.90,3.4"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
at java.lang.Double.parseDouble(Double.java:510)
at RuBank.main(RuBank.java:35)
Process completed.
What am i doing wrong?
This is the code:
import javax.swing.JOptionPane;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class RuBank {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new FileReader("C:/ITM200/Group Project/src/clients.txt"));
BufferedWriter out = new BufferedWriter(new FileWriter("C:/ITM200/Group Project/src/transactions.txt"));
int a,c,e = 0;
String b,d,f;
String line = in.readLine();
int n = Integer.parseInt(line.trim());
String [] client = new String[n];
String[] Names = new String[n];
double[] Balances = new double[n];
double[] Rates = new double[n];
int cntr = 0;
while((line = in.readLine()) != null && cntr < n) {
client[cntr] = line.trim();
a = line.indexOf(",");
b = line.substring(0,a);
c = line.indexOf(",",a+1);
d = line.substring(a+1,c);
e = line.indexOf(",",c+1);
f = line.substring(e+1).trim();
Names[cntr] = b;
Balances[cntr] = Double.parseDouble(d);
Rates[cntr] = Double.parseDouble(f);
cntr ++;
}
int ID = GetID("Enter Your Employee ID");
String Name = GetName("Who is the client?");
}
public static int GetID(String prompt) {
String a = JOptionPane.showInputDialog(prompt);
int b = Integer.parseInt(a.trim());
return b;
}
public static String GetName(String prompt) {
String a = JOptionPane.showInputDialog(prompt);
a = (a.trim()).toLowerCase();
return a;
}
}
5
john sears,23400.90,3.4
kelly fan,11567.80,5.15
jane simms,347.45,2.78
tom sly,3452.22,6.0
seth abe,1211.00,3.6
That how it looks like in the text
It builds but when i run it does this:
--------------------Configuration: <Default>--------------------
Exception in thread "main" java.lang.NumberFormatException: For input string: "john sears,23400.90,3.4"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)
at java.lang.Double.parseDouble(Double.java:510)
at RuBank.main(RuBank.java:35)
Process completed.
What am i doing wrong?