import java.util.Scanner; public class MiniTellerShell { /* in the main method y
ID: 3801228 • 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
This is main and Driver class:
package com.miniTellerShell;
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
*/
static Scanner kb=null;
static double balance = 0;
static double amount;
public static double getBalance() {
return balance;
}
public static void setBalance(double balance) {
MiniTellerShell.balance = balance;
}
public static void main(String[] args)
{
kb = new Scanner(System.in);
String choice ="";
boolean repeat = true;
String answer = "";
boolean account = false;
description();
while (repeat) //as long as there is another user
{
choice = "";
account = false;
displayChoices();
System.out.println("Enter a valid choice: ");
choice=kb.next();
choice=validChoice(choice);
while (!choice.equalsIgnoreCase("Q"))// as long as the user has not selected quit
{
System.out.println("Thanks for being our loyal customer.");
System.out.println("Is there another user?yes/no");
String str =kb.next();
if(str.equals("yes")){
break;
}else{
System.out.println("The system is about to shut down");
System.exit(0);
break;
}
}
}
}
/*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(double amount)
{
balance = balance - amount;
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(double amount)
{
balance = balance + amount;
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(double amount)
{
balance = getBalance() + amount;
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("/////////////// 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 Press C to create a new account press D to deposit press W to withdraw press B for Balance Press Q to quit");
}
/*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(String choice)
{
switch (choice)
{
case "B" :
System.out.print("Your Balance is: "+getBalance());
break;
case "C" :
System.out.println("lets cretae an account for you.");
while(true){
System.out.println(" Enter the initial amount of money: ");
amount =kb.nextInt();
amount=dataValidation(amount);
if(amount>=100){
create(amount);
System.out.println("Your account has been cretaed successfully");
break;
}else{
System.out.println("You must deposit 100 or more to create a new account");
}
System.out.println("Do you want to cretae a new account? yes");
String str =kb.next();
if(str.equals("yes")){
continue;
}else{
break;
}
}
break;
case "W" :
System.out.println("Enter the withdraw Amount: ");
amount =kb.nextInt();
amount=dataValidation(amount);
if((balance-amount)>=100){
withdraw(amount);
System.out.println("The amount of the money that you have is"+getBalance());
}else{
System.out.println("Your balance cannot go below 100 dollars");
System.out.println("your balance after withdraw will be : "+(balance-amount));
System.out.println("The amount of the money that you have is"+getBalance());
}
break;
case "D":
System.out.println("Enter the amount of the money to deposit: ");
amount =kb.nextInt();
System.out.println("Your Balance is: "+getBalance());
deposit(amount);
System.out.println("Your new balance after deposit is: "+getBalance());
break;
case "Q":
break;
default :
break;
}
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(double amount)
{
if(amount>0){
amount=amount;
return amount;
}
else{
System.out.println("You must enter a positive amount of money.");
return 0;
}
}
}
Output:
//////////////////////////////////////////////////////
/////////////// 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 a valid choice:
t
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 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.
You must deposit 100 or more to create a new account
Do you want to cretae a new account? yes
yes
Enter the initial amount of money:
80
You must deposit 100 or more to create a new account
Do you want to cretae a new account? yes
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 a valid choice:
W
Enter the withdraw Amount:
20
Your balance cannot go below 100 dollars
your balance after withdraw will be : 80.0
The amount of the money that you have is100.0
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 a valid choice:
D
Enter the amount of the money to deposit:
100
Your Balance is: 100.0
Your new balance after deposit is: 200.0
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 a valid choice:
D
Enter the amount of the money to deposit:
100
Your Balance is: 200.0
Your new balance after deposit is: 300.0
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 a valid choice:
W
Enter the withdraw Amount:
150
The amount of the money that you have is150.0
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 a valid choice:
B
Your Balance is: 150.0
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 a valid 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.