1.menu of 4 choice
1.desposit
2.withdraw
3.display all desposit and withdraw record
4.exit
(my choice 2 is ok)
(some problem with choice 1)
if choice one
key in amount: 300(example)
confirm Y/N<?>y
thank you for banking with us you have desposit 300.00(example)
if choice one
key in amount: 300(example)
confirm Y/N<?>n
key in the amount you wish to desposit:example (500)
confirm Y/N<?>Y
thank you for banking with us you have desposit 500.00(example)
MY PROGRAMME
import java.util.*;
import java.text.*;
public class BankAccount {
static DecimalFormat fmt=new DecimalFormat("0.00");
static Scanner input=new Scanner(System.in).useDelimiter("\r\n") ;
static final char y = 'Y';
static final char n = 'N';
public static void main(String[] args)throws Exception
{
double desposit=0, withdraw=0 ;
char choice;
boolean execute;
String Confirm;
Scanner keyboard = new Scanner(System.in);
do
{
System.out.println("Welcome to TP's Bank ");
System.out.println("Select 1 option to begin banking with us. ");
System.out.println("1. deposit");
System.out.println("2. withdraw");
System.out.println("3.display all desposit & withdraw record");
System.out.println("4.Exit");
System.out.print("please select 1 choice or press 4 to Exit: ");
choice=(char) System.in.read();
System.in.read();
System.in.read();
switch (choice)
{
case '1':
confirmation();
case '2':
System.out.println("how much do you wish to withdraw?");
withdraw=input.nextDouble();
if (desposit>=withdraw)
System.out.println("youo have withdraw "+(withdraw)+"");
else if (desposit<withdraw)
System.out.println("you do not have enough to withdraw");
System.out.println(" ");
break;
case '3':
System.out.println("============================== ==========");
System.out.println(" Deposit Record ");
System.out.println("============================== ==========");
System.out.println("Date Time Amount");
System.out.println(" " );
System.out.println(" ");
System.out.println("============================== ==========");
System.out.println(" Withdrawal Record ");
System.out.println("============================== ==========");
System.out.println("Date Time Amount");
System.out.println(" " );
System.out.println(" " );
case '4': System.out.println("thank you for banking with TP, hope to see you again ");
break;
default: System.out.println("Invalid choice. Please enter A, B or Q only.\n");
}
} while (choice != '4');
static void confirmation()throws exception
{
System.out.print("key in the amount you wish to desposit: ");
desposit=input.nextDouble();
System.out.print("Confirm Y/N,?. ");
Confirm = keyboard.next();
if(Confirm.equalsIgnoreCase("Y"))
{
confirmation();
}else
{
if(Confirm.equalsIgnoreCase("N"))
}
{
System.out.println("Thank you for banking with us, you have deposit $"+desposit);
}
break;
}// end of switch-case
} //end of
}
PROBLEM ..
cannot do the desire yes or no option and call method illegal start of expression