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:exampl e (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).useDelimite r("\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.prin tln("Welcome to TP's Bank ");
System.out.prin tln("Select 1 option to begin banking with us. ");
System.out.prin tln("1. deposit");
System.out.prin tln("2. withdraw");
System.out.prin tln("3.display all desposit & withdraw record");
System.out.prin tln("4.Exit");
System.out.prin t("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.prin tln("how much do you wish to withdraw?");
withdraw=input. nextDouble();
if (desposit>=with draw)
System.out.prin tln("youo have withdraw "+(withdraw)+"" );
else if (desposit<withd raw)
System.out.prin tln("you do not have enough to withdraw");
System.out.prin tln(" ");
break;
case '3':
System.out.prin tln("========== =============== =============== ");
System.out.prin tln(" Deposit Record ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln("Date Time Amount");
System.out.prin tln(" " );
System.out.prin tln(" ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln(" Withdrawal Record ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln("Date Time Amount");
System.out.prin tln(" " );
System.out.prin tln(" " );
case '4': System.out.prin tln("thank you for banking with TP, hope to see you again ");
break;
default: System.out.prin tln("Invalid choice. Please enter A, B or Q only.\n");
}
} while (choice != '4');
static void confirmation()t hrows exception
{
System.out.prin t("key in the amount you wish to desposit: ");
desposit=input. nextDouble();
System.out.prin t("Confirm Y/N,?. ");
Confirm = keyboard.next() ;
if(Confirm.equa lsIgnoreCase("Y "))
{
confirmation();
}else
{
if(Confirm.equa lsIgnoreCase("N "))
}
{
System.out.prin tln("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
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:exampl e (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).useDelimite r("\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.prin tln("Welcome to TP's Bank ");
System.out.prin tln("Select 1 option to begin banking with us. ");
System.out.prin tln("1. deposit");
System.out.prin tln("2. withdraw");
System.out.prin tln("3.display all desposit & withdraw record");
System.out.prin tln("4.Exit");
System.out.prin t("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.prin tln("how much do you wish to withdraw?");
withdraw=input. nextDouble();
if (desposit>=with draw)
System.out.prin tln("youo have withdraw "+(withdraw)+"" );
else if (desposit<withd raw)
System.out.prin tln("you do not have enough to withdraw");
System.out.prin tln(" ");
break;
case '3':
System.out.prin tln("========== =============== =============== ");
System.out.prin tln(" Deposit Record ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln("Date Time Amount");
System.out.prin tln(" " );
System.out.prin tln(" ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln(" Withdrawal Record ");
System.out.prin tln("========== =============== =============== ");
System.out.prin tln("Date Time Amount");
System.out.prin tln(" " );
System.out.prin tln(" " );
case '4': System.out.prin tln("thank you for banking with TP, hope to see you again ");
break;
default: System.out.prin tln("Invalid choice. Please enter A, B or Q only.\n");
}
} while (choice != '4');
static void confirmation()t hrows exception
{
System.out.prin t("key in the amount you wish to desposit: ");
desposit=input. nextDouble();
System.out.prin t("Confirm Y/N,?. ");
Confirm = keyboard.next() ;
if(Confirm.equa lsIgnoreCase("Y "))
{
confirmation();
}else
{
if(Confirm.equa lsIgnoreCase("N "))
}
{
System.out.prin tln("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