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
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();
}
}



Hm, I am not even seeing an error message.