import java.util.Scanner; public class MiniTellerShell { /* in the main method y
ID: 3801229 • Letter: I
Question
import java.util.Scanner; public class MiniTellerShell { /* in the main method you need to call the method validChoice as long as the user's choice is not Q or q based on the user's choice call the appropriate methods such as balance, depoist, withdraw and cretate once the user select Q or q, prompt the user if there is another customer */ public static void main(String[] args) { Scanner kb = new Scanner(System.in); String choice =""; double balance = 0; description(); boolean repeat = true; String answer = ""; boolean account = false; while (repeat) //as long as there is another user { balance = 0; choice = ""; account = false; while (!choice.equalsIgnoreCase("Q"))// as long as the user has not selected quit { //your code includes conditional statments } } System.out.println("The system is about to shut down"); } /*This method accepts a Scanner object and the balance of the money that the person has as its parameter prompt the user to enter the amount of the money to withdraw call the method dataValiation to get the user's input if the user's input is more than the balance display that the user cannot withdraw that amount if the balance - the user's input is less than 100 then no withdraw can be done otherwise the withdraw can be done therefore the user's input must be subtracted from the balance. then return the new balance */ public static double withdraw(Scanner kb, double balance) { return 0; } /*this method prompt the user for the amount to deposit call the method dataValidation to get the user's input add the amonmut to the balance, return the new balance*/ public static double deposit(Scanner kb, double balance) { return 0; } /* this method prompts the user to enter the initial amount of the money to cretae the account call the method dataValidation if the user's input is less than 100, the account cannot be cretaed otherwise the account will be cretaed and a message will be displayed indicating that the account has been cretaed, the initial amount of the money will be returned */ public static double create(Scanner kb) { return 0; } /* This method outputs Welcome to the Bank of America message including all the back slashes */ public static void description( ) { } /* This method displays the choices that the user has*/ public static void displayChoices() { } /*this method prompts the user to enter the choice as long as the user does not have a valid choice, it will keep prompting the user for a valid choice*/ public static String validChoice(Scanner kb) { return ""; } /*This method accepts the scanner object and a message to be displayed on the screen Outputs the prompt on the screen sking the user to enter the amount As long as the amount is less than zero and as long as the user is entering an invalid double value, this method should keep prompting the user for a valid amount. return the valid amount*/ public static double dataValidation(String prompt, Scanner kb) { return 0; } } /*sample output ____________________________________________________________________________________________________ \\\\\\\\\\\\\\\\\\\\\\ \ Welcome to the Bank of America \ \\\\\\\\\\\\\\\\\\\\\\ Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> r Enter a valid choice ---> t Enter a valid choice ---> c lets cretae an account for you. Enter the initial amount of money--> -20 You must enter a positive amount of money. Enter a valid amount: 80 You must deposit 100 or more to create a new account Do you want to cretae a new account? yes Enter the initial amount of money--> 100 Your account has been cretaed successfully Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> w Enter the amount of the withdraw--> 20 Your balance cannot go below 100 dollars. your balance after withdraw will be :80.0 The amount of the money that you have is-->100.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> w Enter the amount of the withdraw--> 100 Your balance cannot go below 100 dollars. your balance after withdraw will be :0.0 The amount of the money that you have is-->100.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> d Your balance is--> 100.0 Enter the amount of the money to deposit--> 200 Your new balance after deposit is: 300.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> w Enter the amount of the withdraw--> 150 The amount of the money you have--> 300.0 The amount of the money that you have is-->150.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> c You already have an account. Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> B Your balance is --> 150.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> w Enter the amount of the withdraw--> 200 You do not have enough money to withdraw The amount of the money that you have is-->150.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> w Enter the amount of the withdraw--> 51 Your balance cannot go below 100 dollars. your balance after withdraw will be :99.0 The amount of the money that you have is-->150.0 Hit enter key to continue --> Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> q Thanks for being our loyal customer. Is there another user?yes/no yes Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> C lets cretae an account for you. Enter the initial amount of money--> 100 Your account has been cretaed successfully Select one of the following options Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit Enter your choice ---> q Thanks for being our loyal customer. Is there another user?yes/no no The system is about to shut down _____________________________________________________________________________________________________ */
Explanation / Answer
Here is the completed code for the above code template. Sample run similar to the one was done and output is attached. Please don't forget to rate the answer if it helped.Thank you very much.
import java.util.Scanner;
public class MiniTellerShell
{
/* in the main method you need to call the method validChoice
as long as the user's choice is not Q or q
based on the user's choice call the appropriate methods such as balance, depoist, withdraw and cretate
once the user select Q or q, prompt the user if there is another customer
*/
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
String choice ="";
double balance = 0;
description();
boolean repeat = true;
String answer = "";
boolean account = false;
while (repeat) //as long as there is another user
{
balance = 0;
choice = "";
account = false;
while (!choice.equalsIgnoreCase("Q"))// as long as the user has not selected quit
{
displayChoices();
choice=validChoice(kb);
if(choice.equals("C"))//create
{
if(account==false)
{
System.out.println("Lets create an account for you.");
balance=create(kb);
account=true;
}
else
System.out.println("You already have an account.");
}
else if(choice.equals("B"))//balance
{
System.out.println("Your balace is --> " +balance);
}
else if(choice.equals("W"))//withdraw
{
balance=withdraw(kb, balance);
}
else if(choice.equals("D"))//deposit
{
balance=deposit(kb, balance);
}
else if(choice.equals("Q"))
{
System.out.println("Thanks for being our loyal customer.");
System.out.println("Is there another user?yes/no : ");
choice=kb.next();
if(!choice.equalsIgnoreCase("yes"))
repeat=false;
break;
}
String enter;
System.out.println("Hit enter key to continue --> ");
enter=kb.nextLine();
if(enter.isEmpty())
enter=kb.nextLine();
}
}
System.out.println("The system is about to shut down");
}
/*This method accepts a Scanner object and the balance of the money that the person has as its parameter
prompt the user to enter the amount of the money to withdraw
call the method dataValiation to get the user's input
if the user's input is more than the balance display that the user cannot withdraw that amount
if the balance - the user's input is less than 100 then no withdraw can be done
otherwise the withdraw can be done therefore the user's input must be subtracted from the balance. then return the new balance
*/
public static double withdraw(Scanner kb, double balance)
{
boolean repeat=false;
double withdraw;
withdraw=dataValidation("Enter the amount to withdraw ",kb);
if(balance<withdraw)
{
System.out.println("You do not have enough money to withdraw");
}
else if(balance-withdraw<100)
{
System.out.println("Your balance can not go below 100 dollars.");
System.out.println("Your balance after withdrawal will be : "+(balance-withdraw));
System.err.println("The amount of money available for withdrawal :"+balance);
}
else
balance=balance-withdraw;
System.out.println("The amount of money you have now is : "+balance);
return balance;
}
/*this method prompt the user for the amount to deposit
call the method dataValidation to get the user's input
add the amonmut to the balance, return the new balance*/
public static double deposit(Scanner kb, double balance)
{
double amount;
System.out.println("Your balance is -->"+balance);
amount=dataValidation("Enter the amount to deposit ", kb);
balance+=amount;
System.out.println("Your new balance after deposit is -->"+balance);
return balance;
}
/*
this method prompts the user to enter the initial amount of the money to cretae the account
call the method dataValidation
if the user's input is less than 100, the account cannot be cretaed
otherwise the account will be cretaed and a message will be displayed
indicating that the account has been cretaed, the initial amount of the money will be returned
*/
public static double create(Scanner kb)
{
double balance;
boolean repeat=false;
do
{
balance=dataValidation("Enter the initial amount of money --> ",kb);
if(balance<100)
{
System.out.println("You must deposit 100 or more to create a new account.");
repeat=true;
}
else
repeat=false;
}while(repeat);
System.out.println("Your account has been created successfully.");
return balance;
}
/*
This method outputs Welcome to the Bank of America message including all the back slashes
*/
public static void description( )
{
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
System.out.println("\\ Welcome to the Bank of America \\");
System.out.println("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\");
}
/*
This method displays the choices that the user has*/
public static void displayChoices()
{
System.out.println("Select one of the following options");
System.out.println("Press C to create a new account");
System.out.println("press D to deposit");
System.out.println("press W to withdraw");
System.out.println("press B for Balance");
System.out.println("Press Q to quit");
System.out.println("Enter your choice --->");
}
/*this method prompts the user to enter the choice
as long as the user does not have a valid choice, it will keep prompting the user
for a valid choice*/
public static String validChoice(Scanner kb)
{
String options="CDWBQ"; //these are the only letters user can choose
String choice;
do
{
choice=kb.next();
if(options.indexOf(choice.toUpperCase())<0)//did not find your choice in the options string
{
System.out.println("Enter a valid choice --->");
}
else
break;//come out loop since we got a valid option
}while(true);
return choice.toUpperCase();//return the choice after converting to upper case
}
/*This method accepts the scanner object and a message to be displayed on the screen
Outputs the prompt on the screen sking the user to enter the amount
As long as the amount is less than zero and as long as the user is entering an invalid
double value, this method should keep prompting the user for a valid amount.
return the valid amount*/
public static double dataValidation(String prompt, Scanner kb)
{
double balance;
boolean repeat=false;
String prompt1=prompt;
do
{
System.out.println(prompt);
balance=kb.nextDouble();
if(balance<0)
{
prompt="You must enter a positive amount of money. Enter a valid amount : ";
repeat=true;
}
else
repeat=false;
}while(repeat);
return balance;
}
}
sample output
\\\\\\\\\\\\\\\\\\\\\\\
\ Welcome to the Bank of America \
\\\\\\\\\\\\\\\\\\\\\\\
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
r
Enter a valid choice --->
t
Enter a valid choice --->
c
Lets create an account for you.
Enter the initial amount of money -->
-20
You must enter a positive amount of money.
Enter a valid amount :
80
You must deposit 100 or more to create a new account.
Enter the initial amount of money -->
100
Your account has been created successfully.
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
w
Enter the amount to withdraw
20
Your balance can not go below 100 dollars.
Your balance after withdrawal will be : 80.0
The amount of money available for withdrawal :100.0
The amount of money you have now is : 100.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
w
Enter the amount to withdraw
100
Your balance can not go below 100 dollars.
Your balance after withdrawal will be : 0.0
The amount of money available for withdrawal :100.0
The amount of money you have now is : 100.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
d
Your balance is -->100.0
Enter the amount to deposit
200
Your new balance after deposit is -->300.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
w
Enter the amount to withdraw
150
The amount of money you have now is : 150.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
c
You already have an account.
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
b
Your balace is --> 150.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
w
Enter the amount to withdraw
200
You do not have enough money to withdraw
The amount of money you have now is : 150.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
w
Enter the amount to withdraw
51
Your balance can not go below 100 dollars.
Your balance after withdrawal will be : 99.0
The amount of money available for withdrawal :150.0
The amount of money you have now is : 150.0
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
q
Thanks for being our loyal customer.
Is there another user?yes/no :
yes
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
c
Lets create an account for you.
Enter the initial amount of money -->
100
Your account has been created successfully.
Hit enter key to continue -->
Select one of the following options
Press C to create a new account
press D to deposit
press W to withdraw
press B for Balance
Press Q to quit
Enter your choice --->
q
Thanks for being our loyal customer.
Is there another user?yes/no :
no
The system is about to shut down
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.