hi
this program here is my second assignment, it is an upgrade to the first one that I had posted before but with a few more classes added;
I am supposed to used the same set of coding with this one as in the first one but few more coding added to it and it is supposed to run the same way as the first one. the problem I am having is the cannot find symbol, I have tried looking in the respective classes to see where the error is originated from but cannot for the life of me, seem to find it.
as i said, this is my second assignment, it is an upgrade to the first one with just a few more classes added. here is the codes and class
the atm is the main class this is where the program will run from. can someone tell me how to fix it
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 | public class ATM { DecimalFormat df = new DecimalFormat( "#.00" ); public static void main(String[] args) { createAccount(); } public static void createAccount() { Scanner input = new Scanner(System.in); int i= 0 ; double bal= 50.0 ; //this account hold 10 account Account[] acct = new Account[ 10 ]; //creating a new person Person[] p = new Person[i++]; for (i= 0 ; i<acct.length; i++){ System.out.println( "Enter your name" ); String n = input.next(); System.out.println( "Enter your address" ); String a = input.next(); System.out.println( "Enter your contact" ); String c = input.next(); System.out.println( "Enter the client number" ); int cn = input.nextInt(); //creating a new client each time the program runs Clients client = new Clients(n, a, c, cn); } //asking the user to enter the type of account they want to utilize System.out.println( "Welcome to the Account Type:\n " ); System.out.println( "Please select from the following menu option:\n" ); System.out.println( "=======================================" ); System.out.println( "| Please select your account type | " ); System.out.println( "=======================================" ); System.out.println( "| [\n1] Savings Account |" ); System.out.println( "| [\n2] Checking Account |" ); System.out.println( "| [\n3] CreditCard Account |" ); System.out.println( "======================================" ); int accType = input.nextInt(); if (accType == 1 ) { acct[i] = new SavingsAccount(i, bal, client); this is where I am getting the cannot find symbol error(client- is the error) } else if (accType == 2 ) { acct[i] = new CheckingAccount(i, bal, client);his is where I am getting the cannot find symbol error(client- is the error) } else if (accType == 3 ) { acct[i] = new CreditCardAccount(i, bal, client);his is where I am getting the cannot find symbol error(client- is the error) } while ( true ) { System.out.println( "Enter your account id" ); int id = input.nextInt(); if (id == - 1 ) { break ; } //this loop indicate that the id should be between 1 - 9 while (id < 0 || id > 9 ) { System.out.println( "ID is incorect, try again" ); id = input.nextInt(); } //this while indicate whether the user enter the wrong id, given another chance to re-enter while ( true ) { displayMenu(); if (!useMenu(acct[id],input)) { System.out.println(); break ; } System.out.println( "\n" ); } } } public static boolean useMenu(Account acc, Scanner input) { int userchoice = input.nextInt(); //everytime it runs it shall be false until it is true double amt= 0 ; if (userchoice == 5 ) { return false ; } else if (userchoice == 1 ) // { //user checking their balances System.out.println( "The account balance is: " + acc.getbalance()); return true ; } else if (userchoice == 2 ) { //indicating the amount to be withdrawn System.out.println( "Enter the amount to withdraw" ); amt =input.nextDouble(); //hold the amt to be withdrawn if (amt > acc.getbalance()) //indicating if the amt withdrwn is over the limit { //indicating that there is not enough funds in the account System.out.println( "Insufficient amount " + "Balance is " +acc.getbalance()); } else { //otherwise there is enought to be withdrawn acc.withdraw(amt); System.out.println( "Balance is: " + acc.getbalance()); } } else if (userchoice == 3 ) { //user is asked to enter the amount to be deposited System.out.println( "Enter the amount to deposit" ); acc.deposit(input.nextDouble()); //hold the amt deposited System.out.println( "Balance is " + acc.getbalance()); //gathering the balance after the transactions return true ; } else if (userchoice == 4 ) { //gathering the user information System.out.println(acc.getClient().toString()); } else { //this indicated that the user enter a choice that is not there. System.out.println( "invalid choice" ); } return true ; } public static void displayMenu() { //displaying the menu where the user has to choose from System.out.println( "Welcome to the Automated Teller Machine!\n" ); System.out.println( "Select from the following menu options below:\n" ); System.out.println( "=======================================" ); System.out.println( "| Main Menu |" ); System.out.println( "=======================================" ); System.out.println( "| [1] Check Balance |" ); System.out.println( "| [2] Withdraw |" ); System.out.println( "| [3] Deposit |" ); System.out.println( "| [4] Display User Information |" ); System.out.println( "| [5] Exist |" ); System.out.println( "Please select your choice now!! |" ); System.out.println( "=======================================" ); } } this is the account class public abstract class Account { //instantiate the variable private int id; private double balance; private Clients client; private double acctTransaction; //constructor with parameter, this initialiing the id, bal and client number public Account( int i, double b, Clients c) { id = i; balance = b; client = c; acctTransaction= 0 ; } // getting clients public Clients getClient() { return client; } // getting accid public int getid() { return id; } // getting balance public double getbalance() { return balance; } //setting clients public void setClients(Clients client) { this .client = client; } //setting accid public void setid( int id) { this .id = id; } // setting balance public void setbalance( double balance) { this .balance = balance; } public void setacctBalance( double balance){ this .balance = balance; } public abstract void withdraw( double amt); public abstract void deposit( double amt); @Override // getting user information public String toString(){ String getdetails = "acct ID " +id+ "balance " +balance + "\nClient " +client.toString(); return getdetails; } public void reviseTransaction(){ acctTransaction++; } public double getacctTransaction(){ return acctTransaction; } } this is the checkingAccount class package Project; /** * * @author luanataylor */ public class CheckingAccount extends Account { //intantiate variable private final double withdraw; //constructor with parameter public CheckingAccount( int i, double b, Clients c, double w) { super (i, b, c); //refering to the variable in the parents class withdraw = 0.3167 ; } public void deposit( double amt){ super .setbalance( super .getbalance() + amt); } @Override public void withdraw( double amt) { reviseTransaction(); // transaction is being updated if (amt > super .getbalance()) { //super calling the getbalance super .setacctBalance( super .getbalance() - amt); if ( super .getacctTransaction() > 10 ) applyFee(); } } //applying the fee public void applyFee() { double Tempbalance = super .getbalance() - 0.3167 ; super .setbalance(Tempbalance); } @Override //gathering the information needed public String toString() { return super .toString() + " -> CheckingAccount:\n\t" + "acct balance " + super .getbalance() + " num of account transaction " + super .getbalance(); } } this is the client class public class Clients extends Person{ //instantiate the variable private final int clientNumber; //constructor with parameter public Clients(String n, String a, String c, int cn) { super (n, a, c); clientNumber = cn; } public int getclientNumber() { return clientNumber; } //getting user detailsride @Override public String toString() { return super .toString()+ "\nClient Number " + clientNumber; } this is the creditcard class public class CreditCardAccount extends Account { private final double withdrawTax; public CreditCardAccount( int i, double b, Clients c, double w) { super (i, b, c); withdrawTax = 0.1075 ; } public double getwithdrawTax(){ return withdrawTax; } @Override public void deposit( double amt){ super .setbalance( super .getbalance() + amt); } @Override public void withdraw( double amt){ reviseTransaction(); if (amt > super .getbalance()){ super .setacctBalance( super .getbalance() - amt); if ( super .getacctTransaction() > 10 ) applyFee(); } } public void applyFee(){ double TempBalance = super .getbalance()- 0.1075 ; super .setbalance(TempBalance); } public String toString(){ return super .toString()+ "\n CreditCardAccount " + "Account Balance " + super .getbalance(); } } this is the person class package Project; public abstract class Person { //instantiating the variables private String name; private String address; private String contact; private Person person; //implementing the constructor with arguements public Person(String n, String a, String c) { name = n; address = a; contact = c; } public Person getperson(){ return person; } //getting name public String getname(){ return name; } //getting address public String getaddress(){ return address; } //getting contact public String getcontact(){ return contact; } public void setPerson(Person person){ this .person = person; } //setting the name public void setname(String newName){ this .name = newName; } //setting address public void setaddress(String newaddress){ this .address = newaddress; } //setting contact public void setcontact(String newContact){ this .contact = newContact; } //toString to display the client information @Override public String toString(){ String details = " name " +name+ "\naddress " +address+ "\ncontact " +contact+ "\nPerson " +person; return details; } } this is the savingsaccount class package Project; public class SavingsAccount extends Account { //instantiating the variables double balance; //constructor with parameters public SavingsAccount( int i, double b, Clients c) { super (i, b, c); //this is refering the variables in the parent class } @Override public void deposit( double amt) { super .setbalance( super .getbalance() + amt); } @Override //get the withdra method public void withdraw( double amt) { reviseTransaction(); if (amt > super .getbalance()) { // calling the balance method super .setacctBalance( super .getbalance() - amt); //calculating the balance from the amt } } @Override //gathering the account information public String toString() { return super .toString()+ "-> Saving Account " + "account balance " + super .getbalance(); } } |