ok new problem... for some reason the code wont enter the if statements even when i know its true.... any suggestions
here's the code
Code:
package proj;
import java.lang.*;
import java.util.*;
import java.io.*;
import proj.Store;
/**
*
* @author gmanr26
*/
public class Main {
public static String file = "c:\\test.txt";
public static File dir = new File (file);
public static void main(String[] args) throws IOException, ArrayIndexOutOfBoundsException {
//System.out.print ("here");
//System.out.print (dir.exists());
if (dir.exists()){
Scanner stuff = new Scanner (dir);
//System.out.print (stuff.hasNext());
while (stuff.hasNext()){
if ((stuff.next())=="NEWCUST"){
String cust_num = stuff.next();
stuff.next();
String dob = stuff.next() + "/" + stuff.next() + "/" + stuff.next();
stuff.next();
String sex = stuff.next();
stuff.next();
String name = null;
while (stuff.next()!= "HOME#") {
name = name + " " + stuff.next();
}
String home_num = stuff.next();
stuff.next();
String cell_num = stuff.next();
stuff.next();
String work_num = stuff.next();
stuff.next();
String email = stuff.next();
stuff.next();
Integer ln = Integer.parseInt(stuff.next());
String addr= null;
while (ln >0){
addr = addr + " " + stuff.nextLine();
}
Store inst = new Store();
inst.new_cust (cust_num,dob,sex,name,home_num,cell_num,work_num,
email,addr);
System.out.print ("New Customer " + cust_num +
"\n"+ " Date of Birth " + dob +
"\n" + " Gender" + sex +
"\n" + name +
"\n" + " Home# " + home_num +
"\n" + " Cell# " + cell_num +
"\n" + " Work# " + work_num +
"\n" + " E-Mail " + email +
"\n" + " Address " + addr);
}
else {
if (stuff.next()=="OPEN"){
String acc_type = stuff.next();
String acc_num = stuff.next();
stuff.next();
String cust_num = stuff.next();
stuff.next();
String date_opened = stuff.next() + "/" + stuff.next() +
"/" + stuff.next();
stuff.next();
String bal = stuff.next();
Store inst = new Store();
inst.new_acc (acc_type,acc_num,cust_num,date_opened,bal);
System.out.print ("New Account Opened: " +
"\n" + acc_type + " " +
"\n" + "Account Number " + acc_num +
"\n" + "Customer Number " + cust_num +
"\n" + "Date Opened " + date_opened +
"\n" + "Opening Balance " + bal);
}
else {
if (stuff.next()=="GETBAL"){
String acc_num = stuff.next();
Store inst = new Store();
String bal = inst.get_bal (acc_num);
if (bal == null) {
System.out.print ("Account does not exist");
}
else {
System.out.print("The balance of account # " +
acc_num + " is " + bal);
}
}
else {
if (stuff.next()=="DEP"){
String acc_num = stuff.next();
String dollars = stuff.next();
Store inst = new Store();
inst.deposit(acc_num,dollars);
Store inst2 = new Store();
String bal = inst.get_bal(acc_num);
System.out.print("Account " + acc_num + " has been credited " +
"with " + dollars + " and it now has a balance of " +
bal);
}
else {
if (stuff.next()=="WDRAW"){
String acc_num = stuff.next();
String draw = stuff.next();
Store inst = new Store();
inst.withdraw(acc_num,draw);
Store inst2 = new Store();
String bal = inst2.get_bal(acc_num);
System.out.print("Account " + acc_num + " has been debited " +
"with " + draw + " and it now has a balance of " +
bal);
}
else {
if (stuff.next()=="CLOSE"){
String acc_num = stuff.next();
Store inst = new Store();
inst.end_acc(acc_num);
System.out.print("The account "+ acc_num +
" has been officially closed.");
}
else {
stuff.next();
}
}
}
}
}
}
}
}
}
}
and here is the text document its reading
Code:
NEWCUST 1977 DOB 17 07 1887 GENDER M TITLE Hon NAME Marcus Mosiah Garvey
HOME# 927-7777
CELL# N/A
WORK# 977-7777
EMAIL N/A
ADDR 2
1 Lady Musgrave Ave
Kingston 5 Jamaica
OPEN SAVINGSACCT 5676 CUST 1977 OPENED 12 02 2006 BAL 500.00
GETBAL 5676
DEP 5767 250.00
WDRAW 5676 100.00
NEWCUST 1675 DOB 10 12 1988 GENDER F TITLE Ms NAME Mary Q Studious
HOME# N/A
CELL# N/A
WORK# N/A
EMAIL N/A
ADDR 4
Hackers Computer Club
c/o Dept of Computer Science
UWI Mona
Kingston 7 Jamaica
OPEN CHECKINGACCT 2035 CUST 1675 OPENED 11 15 2006 BAL 50.00
DEP 5676 500.00
DEP 2035 400.00
GETBAL 2035
WDRAW 2035 700.50
GETBAL 2035
CLOSE 2035
DEP 2035 700.00
WDRAW 2035 200.00
GETBAL 2035
NEWCUST 1598 DOB 23 01 1981 GENDER F TITLE Mrs NAME June S Johnson
HOME# 989-1364
CELL# 844-9056
WORK# 998-5422
EMAIL wilma@yahoo.com
ADDR 3
23 Wildman Avenue
Linstead
St Catherine Jamaica
OPEN SAVINGSACCT 4354 CUST 1598 OPENED 25 09 2006 BAL 10500.00
DEP 4354 289
GETBAL 4354
DEP 5676 200.00
WDRAW 4354 950.00
DEP 4354 1.00
NEWCUST 1188 DOB 18 11 1983 GENDER M TITLE Mr NAME Brian J McDonald
HOME# N/A
CELL# 254-1527
WORK# 928-7734
EMAIL fredfilmstone@gmail.com
ADDR 2
Stanton Terrace
Kingston 5
OPEN SAVINGSACCT 5441 CUST 1188 OPENED 25 09 2006 BAL 500.00
OPEN CHECKINGACCT 7888 CUST 1188 OPENED 26 09 2006 BAL 2000.00
WDRAW 5441 885.00
DEP 7888 1200.00
GETBAL 7888
GETBAL 5441
NEWCUST 1122 DOB 13 10 1982 GENDER F TITLE Mrs NAME Cova L Sinclair
HOME# 705-1143
CELL# N/A
WORK# N/A
EMAIL girl2000@cwja.com
ADDR 1
Kingston CSO
OPEN CHECKINGACCT 7123 CUST 1122 OPENED 16 01 2006 BAL 2354.00
GETBAL 7123
WDRAW 7123 23.00
CLOSE 5441
NEWCUST 1099 DOB 15 08 1973 GENDER F TITLE Miss NAME Eve Michelle Thomas
HOME# 453-7890
CELL# 677-9087
WORK# 978-8908
EMAIL N/A
ADDR 2
16 August Town Rd
Kingston 3
OPEN SAVINGSACCT 5444 CUST 1099 OPENED 25 09 2006 BAL 3459.00
GETBAL 5444
WDRAW 5444 459.00
WDRAW 5444 3500.00
WDRAW 5444 3000.00
GETBAL 5444
DEP 5444 200.00
GETBAL 7000
DEP 7000 100.00
WDRAW 7000 100.00
OPEN SAVINGSACCT 8000 CUST 1500 OPENED 14 02 2006 BAL 200.00
any suggestions.... please help me....