I'm somewhat of an newbie when java programming and would appreciate some help with the code below. This class is part of a banking system code and comes up with an error (within the switch case1) that displays "cannot find symbol - method DisplayInfo()" error. I've tried to solve this error, but I'm stuck and need some help. I know that sometimes this error comes up when something is accidentally spelled wrong, but I double checked all of the code and couldn't find an error in relation to this.
import java.util.Scanner;
public class ATM
{
static Scanner scan = new Scanner(System.in);
private static int choice;
private String Name;
private int birthday;
private int AccountSocial;
private static String AccountName;
private String day, month, year;
public static void main (String[] args)
{
Bank a = new Bank();
Transaction t = new Transaction();
printMenu();
choice = scan.nextInt();
if(a.getAccountCount() < a.getAccountCapacity())
{
while(choice !=7)
{
menuChoice(choice);
printMenu();
choice = scan.nextInt();
}
if(choice == 7)
menuChoice(7);
}
else
while(choice !=6)
{
menuChoice2(choice);
printMenu();
choice = scan.nextInt();
}
if(choice == 6)
menuChoice2(6);
}
//Menu
public static void printMenu()
{
System.out.println(" What would you like to do? ");
System.out.println("2. Deposit Money. ");
System.out.println("3. Withdraw Money. ");
System.out.println("4. Display Balance. ");
System.out.println("5. Display Last transaction info.");
System.out.println("6. Create a new bank accountount.");
System.out.println("7. Quit. ");
}
//Switch Method used for menu
public static void menuChoice(int choice)
{
switch(choice)
{
case 1:
System.out.println("Which account would you like to alter?");
int i = scan.nextInt();
DisplayInfo();
break;
case 2:
System.out.println("How much money would you like to deposit?");
double x = scan.next();
break;
case 3:
System.out.println("How much money would you like to withdraw?");
x = scan.next();
b.withdraw(x, a, B)/>;
break;
case 4:
b.getAccountBalance();
break;
case 5:
b.getLastTrans(B)/>;
break;
case 6:
setCreDate();
System.out.println("We will need some information from you before "+
"we create\n this bount.");
System.out.println("What year were you born in? (0000) ");
year = scan.next();
System.out.println("What month were you born in? (00) ");
month = scan.next();
System.out.println("What day were you born in? (00) ");
day = scan.next();
setBirth(day, month, year);
setSocial();
System.out.println();
a.addToBank(getCreDate(), getSocial(), getBirth());
break;
case 7:
System.out.println("Have a nice day.");
System.exit(0);
break;
}
}
public static void menuChoice2(int choice)
{
switch(choice)
{
case 1:
a[b].DisplayInfo();
break;
case 2:
System.out.println("How much money would you like to deposit?");
double x = scan.nextDouble();
b.deposit(x, a, B)/>;
break;
case 3:
System.out.println("What amount would you like to withdraw?");
x = scan.nextDouble();
a.withdraw(x, a, B)/>;
break;
case 4:
a.getAccountBalance();
break;
case 5:
a.getLastTrans(B)/>;
break;
case 6:
System.out.println("Have a nice day.");
System.exit(0);
break;
}
}
}
^The code above has the issue. The code sections below are in relation to this one.
import java.util.Scanner;
public class Account
{
Scanner scan = new Scanner(System.in);
String AccountName;
int AccountNumber;
double AccountBalance;
String AccountBirth;
String AccountSocial;
String lastChange;
double lastAmount;
String day, month, year;
String soc1, soc2, soc3;
String creationDate;
int socT1 = 3;
int socT2 = 2;
int socT3 = 4;
boolean fail = false;
// Transactions
private Transaction[] Account;
final int transactionCapacity = 10;
private int transactionCount = 0;
//////////////////////////////////////////////////////////////////////////////////
///////////////////////// Constructor ////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public Account()
{
AccountNumber = (int) (Math.random() * Integer.MAX_VALUE);
AccountBalance = 0.0;
creationDate = null;
AccountSocial = null;
//Transactions
Account = new Transaction[transactionCapacity];
}
public Account(String Date, String Social, String Birth)
{
AccountNumber = (int) (Math.random() * Integer.MAX_VALUE);
AccountBalance = 0.0;
creationDate = Date;
AccountSocial = Social;
// Transactions
Account = new Transaction[transactionCapacity];
}
//////////////////////////////////////////////////////////////////////////////////
/////////////////////////// Add to Account /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public void addToAccount(String lastAmount, String lastChange, String date)
{
Account[transactionCount] = new Transaction();
Account[transactionCount].setAmount(lastAmount);
Account[transactionCount].setType(lastChange);
Account[transactionCount].setDate(date);
if (transactionCount < 8)
transactionCount++;
else
transactionCount = 0;
}
//////////////////////////////////////////////////////////////////////////////////
///////////////////////// Withdraw //////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public void withdraw(String amount, Account a)
{
int changeAmount = Integer.parseInt(amount);
if (AccountBalance-50 >= changeAmount)
{
subBalance(changeAmount);
a.addToAccount(amount, "withdraw", getCurDate());
System.out.println("You currently have "+ getAccountBalance() +
" dollars in your ");
}
else
System.out.println("Insufficient funds");
}
//////////////////////////////////////////////////////////////////////////////////
///////////////////////// Deposit ////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public void deposit(String amount, Account a)
{
int changeAmount = Integer.parseInt(amount);
addBalance(changeAmount);
a.addToAccount(amount, "deposit", getCurDate());
System.out.println("You currently have "+ getAccountBalance() +
" dollars in your ");
}
//////////////////////////////////////////////////////////////////////////////////
///////////////////////// Change money ///////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public double addBalance(double newBal)
{
AccountBalance += newBal;
return AccountBalance;
}
public void subBalance(double newBal)
{
AccountBalance -= newBal;
}
//////////////////////////////////////////////////////////////////////////////////
//////////////////////// Social Security /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
public String getSocial()
{
return AccountSocial;
}
public void setSocial()
{
do
{
System.out.println("Please enter your Social Security Number (xxx xx xxxx)");
soc1 = scan.next();
int a = soc1.length();
soc2 = scan.next();
int b = soc2.length();
soc3 = scan.next();
int c = soc3.length();
if(a == 3)
{
if(b == 2)
{
if(c == 4)
{
AccountSocial = (soc1 +"-"+ soc2 +"-"+ soc3);
break;
}
else
{
System.out.println("Invalid input");
fail = true;
}
}
else
{
System.out.println("Invalid input");
fail = true;
}
}
else
{
System.out.println("Invalid input");
fail = true;
}
}
while (fail = true);
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////// Account Number /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
public int getAccountNumber()
{
return AccountNumber;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////// Date //////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
public String getBirth()
{
return AccountBirth;
}
public void setBirth(String day, String month, String year)
{
day = day;
month = month;
year = year;
AccountBirth = day +"/"+ month +"/"+ year;
}
public String getCreDate()
{
return creationDate;
}
public String getCurDate()
{
return creationDate;
}
public void setCreDate()
{
System.out.println("What is the current date? (ex: 02 05 1984)");
day = scan.next();
month = scan.next();
year = scan.next();
creationDate = (day +"/"+month+"/"+year);
}
////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
/////////////////////// Gets Balance /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
public double getAccountBalance()
{
return AccountBalance;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////// Checks to see if 2 accounts are equal /////////////////
/////////////////////////////////////////////////////////////////////////////////
public boolean equals(Account B)/>
{
if (b.AccountNumber == this.AccountNumber)
return true;
else
return false;
}
/////////////////////////////////////////////////////////////////////////////////
/////////////////////// Display Account Info /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
public void DisplayInfo()
{
System.out.println("Your social security is: "+getSocial());
System.out.println("You were born on: "+getBirth());
System.out.println("Account Number: "+getAccountNumber());
System.out.println("You currently have $"+getAccountBalance()+" in your bank right now.");
System.out.println("The account was created on: "+getCreDate());
}
}
import java.util.ArrayList;
public class Bank
{
private int accountCount;
private int accountLimit;
private int accountCapacity;
private Account[] Bank;
String BankName;
/////////////////////////////////////////////////////////////////////////
/////////////////////// Constructor ///////////////////////////////////
/////////////////////////////////////////////////////////////////////////
public Bank()
{
accountCapacity = 10;
accountCount = 0;
Bank = new Account[accountCapacity];
BankName = "Charter";
}
/////////////////////////////////////////////////////////////////////////
/////////////// Adds an Account to the Bank ///////////////////////////
/////////////////////////////////////////////////////////////////////////
public void addToBank(String date, String SSN, String birth)
{
Bank[accountCount] = new Account(date, SSN, birth);
accountCount++;
}
/////////////////////////////////////////////////////////////////////////
/////////////////// Displays bank info /////////////////////////////////
/////////////////////////////////////////////////////////////////////////
public void dispInfo(String bankName, Account number)
{
System.out.println("This bank is named: "+bankName);
number.getAccountNumber();
}
/////////////////////////////////////////////////////////////////////////
////////////////////// Returns the Bank Account ////////////////////////
/////////////////////////////////////////////////////////////////////////
public Account getBankAccount(int i)
{
return Bank[i];
}
public int getAccountCount()
{
return accountCount;
}
public int getAccountCapacity()
{
return accountCapacity;
}
}
public class Transaction
{
String lastAmount;
String lastChange;
String date;
public Transaction()
{
lastAmount = null;
lastChange = null;
date = null;
}
public String getAmount()
{
return lastAmount;
}
public String getType()
{
return lastChange;
}
public String getDate()
{
return date;
}
public void setAmount(String newAmount)
{
lastAmount = newAmount;
}
public void setType(String newType)
{
lastChange = newType;
}
public void setDate(String newDate)
{
date = newDate;
}
public String toString()
{
return "Last transaction info: Type: " + lastChange + " Amount: $" + lastAmount + " Date: " + date;
}
}

New Topic/Question
Reply



MultiQuote








|