Part 2: JAVA Programming (20 points) Algorithms and Output Specification Impleme
ID: 669995 • Letter: P
Question
Part 2: JAVA Programming (20 points)
Algorithms and Output Specification
Implementation Details for the Bank Account
This program should be implemented using only one class named "Assignment3". The program must contain a main method only.
The bank provides three types of accounts:
1.Basic Account: where the total balance of saving and checking is between 0 to 1000 - Interest rate is 2.5% (0.025)
2.Premium Account: where the total balance of saving and checking is at least 1000 and up to (and including) 5000 - Interest rate is 3.5%
3.Platinum Account: where the balance is over 5000 - Interest rate is 4.5%
Creating the bank account
When the program begins the following text should be displayed:
Welcome to CSE110 Bank
What is your name? _
Notice that the cursor is on the same line as
the prompt ("What is your name? ").
The program reads and saves the name in a variable to use later.
The program will then ask for an initial deposit into savings. This value must be saved for later use. You can assume that the user will enter a positive amount.
For example:
Initial deposit into Savings: 1000
The program will then ask for an initial
deposit into checking. This value must be saved for later use.
For example:
Initial deposit into Checking: 500
Main Menu Display
After the account is created the user can deposit money, withdraw money, or transfer money until they
choose to quit.
The menu to be displayed:
Bank Options:
1. Deposit Money
2. Withdraw Money
3. Transfer Money
4. Quit
Your choice:
The user will enter a number that is between 1 and 4.
After the user enters a valid action the account balance will be dis
played, for example:
David's Account balance: $1500.00 (S: $1000.00, C: $500.00)
The current type
of account should be displayed
(the balances can of course be different than those
displayed)
1. Deposit Money
The first option is to deposit money. When the user
selects this option, the following menu is displayed:
Deposit Money Options:
1. Deposit to Checking
2. Deposit to Savings
3. Cancel
Your choice: 1
Amount to deposit to Checking:
150
After the amount is successfully entered, a final message is
displayed (replace "Checking" with "Savings"
when appropriate):
You deposited $150.00 to Checking.
2. Withdraw Money
The second option is to withdraw money. When the user selects this option, the following menu is
displayed:
Withdraw Money Options:
1.Withdraw from Checking
2. Withdraw from Savings
3. Cancel
Your choice:1
Once an option has been chosen, the action is taken. If the user chooses option 3 (Cancel) "Cancel Withdraw." is displayed and the program will terminate.
If they choose 1 or 2 the prompt is displayed
asking for the amount to be withdrawn. It can be either for checking:
Amount to withdraw from Checking:
or for savings:
Amount to withdraw from Savings:
For example:
Withdraw Money Options:
1. Withdraw from Checking
2. Withdraw from Savings
3. Cancel
Your choice:1
Amount to withdraw from Checking:300
After the amount is successfully entered, a final message is displayed
(see the sample execution for an
example). If the user enters option 3 the program terminates.
3. Transfer Money
The third option is to transfer money. When the user selects this option, the following menu is displayed:
Transfer Money Options:
1. Transfer from Checking to Savings
2. Transfer from Savings to Checking
3. Cancel
Your choice: 1
If the user chooses option 3 (Cancel) "Cancel Transfer." is displayed (see the sample execution for an example). If they choose 1 or 2 the prompt is displayed asking for the amount to be withdrawn. It can be
either for checking:
Amount to transfer from Checking to Savings:
or for savings:
Amount to transfer from Savings to Checking:
An example is shown below:
Example 1
Transfer Money Options:
1. Transfer from Checking to Savings
2. Transfer from Savings to Checking
3. Cancel
Your choice: 1
Amount to transfer from Checking to Savings:250
You transferred $250.00 from Checking to Savings.
Transaction Finished Message
After every transaction is completed (other than quitting) a message is displayed. This is displayed even
when the user cancels the selected action (option 3 "Cancel" on the menu):
After this transaction your balance is: $1200.00 (S: $1000.00, C: $200.00)
This message is the same no matter which type of transaction occurred.
Interest will be added before terminating the program.
Displaying Amount
All amounts should be displayed.
Assumptions:
•User will enter valid amount & choices
•You do not need to check for insufficient funds.
Sample Run#1
: User input is in bold
Welcome to CS110 BANK
What is your name? Albert Einstein
Initial deposit into Savings:1500
Initial deposit into Checking:1000
Albert Einstein's Premium Account balance: $2,500.00 (S: $1,500.00, C: $1,000.00)
Bank Options:
1. Deposit Money
2. Withdraw Money
3. Transfer Money
4. Quit
Your choice: 1
Deposit Money Options:
1. Deposit to Checking
2. Deposit to Savings
3. Cancel
Your choice: 1
Amount to deposit to Checking: 250
You deposited $250.00 to Checking.
After this transaction your balance is:
$2,750.00 (S: $1,500.00, C: $1,250.00)
We have added interest to your account! (S: $1,552.50, C: $1,293.75)
I have been working on this program for days now and I have been seriously struggling, Please help and ensure the program matches the question and works. THANK YOU!!
Explanation / Answer
ITS your luck i have done this for someone already.Hope you like this
import java.util.Scanner;
public class Assignment3
{
public static void main(String[] args)
{
System.out.println("******CSE110 BANK******");
Scanner s=new Scanner(System.in);
System.out.print("What is your name? ");
String name=s.nextLine();
System.out.print("Initial deposit into savings: ");
double iDep=s.nextDouble();
System.out.print("Initia; deposit into Checking: ");
double interest,intDep,intChe, iChe=s.nextDouble();
int flag=0;
double dep, bal=iDep+iChe;
System.out.println(name+"'s"+" Account balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
do{
System.out.print("Bank Options: 1.Deposit Money 2.Withdraw Money 3.Transfer Money 4.Quit YourChoice: ");
int opt=s.nextInt();
switch(opt){
case 1:
System.out.print("Bank Options: 1.Deposit to Checkings 2.Deposit to Savings 3.cancel YourChoice: ");
int opt1=s.nextInt();
if(opt1==1){
System.out.print("Amount to deposit to Checking: ");
dep=s.nextDouble();
iChe=iChe+dep;
bal=bal+dep;
System.out.println("You deposited $"+dep+"to Checking");
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else if(opt1==2){
System.out.print("Amount to deposit to Savings: ");
dep=s.nextDouble();
iDep=iDep+dep;
bal=bal+dep;
System.out.println("You deposited $"+dep+"to Savings");
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else{
System.out.println(name+"'s"+" Account balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Cancelling!!!!!!");
}
break;
case 2:
System.out.print("Bank Options: 1.Withdraw to Checkings 2.Withdraw to Checkings 3.cancel YourChoice: ");
int opt2=s.nextInt();
if(opt2==1){
System.out.print("Amount to withdraw from Checking: ");
dep=s.nextDouble();
if(dep<=iChe){
iChe=iChe-dep;
bal=bal-dep;
System.out.println("You Withdrawn $"+dep+"from Checking");
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else{
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Insufficient funds:");
}
}else if(opt2==2){
System.out.print("Amount to withdraw from Savings: ");
dep=s.nextDouble();
if(dep<=iDep){
iDep=iDep-dep;
bal=bal-dep;
System.out.println("You Withdrawn $"+dep+"from Checking");
System.out.println(" After this transaction your balance:"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else{
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Insufficent funds!!!");
}
}else{
System.out.println(name+"'s"+" Account balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Cancelling!!!!!!");
}
break;
case 3:
System.out.print("Bank Options: 1.Transfer from Checking to Savings 2.Transfer from Savings to Checking 3.cancel YourChoice: ");
int opt3=s.nextInt();
if(opt3==1){
System.out.print("Amount to transfer from Checking to Savings:");
double trans=s.nextDouble();
if(trans<=iChe){
System.out.println("You transferred $"+trans+"from Checking to savings.");
iChe=iChe-trans;
iDep=iDep+trans;
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else{
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Insufficient Funds!!!!!");
}
}else if(opt3==2){
System.out.print("Amount to transfer from Savings to Checking:");
double trans=s.nextDouble();
if(trans<=iDep){
System.out.println("You transferred $"+trans+"from Savings to Checking.");
iChe=iChe+trans;
iDep=iDep-trans;
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
}else{
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Insufficient Funds!!!!!");
}
}else{
System.out.println(" After this transaction your balance: $"+bal+" (S:$"+iDep+", C:$"+iChe+")");
System.out.println("Cancelling!!!!!!");
}
break;
default:
flag=1;
break;
}
if(bal<1000){
interest=0.025*bal;
intChe=0.025*iChe;
intDep=0.025*iDep;
iDep=iDep+intDep;
iChe=iChe+intChe;
System.out.println(" We have added interest to your account: $"+"(S:$"+iDep+", C:$"+iChe+")");
}else if(bal<=5000){
interest=0.035*bal;
intChe=0.035*iChe;
intDep=0.035*iDep;
iDep=iDep+intDep;
iChe=iChe+intChe;
System.out.println(" We have added interest to your account: $"+"(S:$"+iDep+", C:$"+iChe+")");
}else{
interest=0.045*bal;
intChe=0.045*iChe;
intDep=0.045*iDep;
iDep=iDep+intDep;
iChe=iChe+intChe;
System.out.println(" We have added interest to your account: $"+"(S:$"+iDep+", C:$"+iChe+")");
}
}while(flag==0);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.