Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java, The user then must choose which account they would like to make a trans

ID: 3833749 • Letter: I

Question

In Java,

The user then must choose which account they would like to make a transaction: Savings Account or Checking Account, or Loan Payment (such as a mortgage, a car loan, or a student loan). If the user chooses a savngs account, then the allowed transactions are either to add money to the saving account, or to withdraw money from the savings account. A balance must be given to the user at the end of the transaction. Assume that the user has a starting balance of $4000 in each of their checking and savings accounts. Error trapping: if a balance goes below $200, then an alert to the user will be issued.

For the loan payments, the user is to choose whether the loan is for a mortgage, a student loan, an auto loan, or a personal loan. For Mortgage: assume $350,000 balance and payment of $3500 per month; For Student Loan: assume $75,000 balance and payment of $250 per month; For Auto Loan, assume $35,000 balance and payment of $500 per month; For Personal Loan, assume $5,000 and payment of $1000 per month.

Test data: for savings account in order: deposit $2000, deposit $1500, withdraw $2500, final balance

Test data for checking account in order: checks (in order) made in the amount of $120, $40, $700, $50, $1000, final balance.

Test data for loan payment(s): see above and provide for at least two payments.

Explanation / Answer

Java code:

import java.util.Scanner;

public class Account{

    Scanner s = new Scanner(System.in);

    double savingsAccountBalance = 4000;

    double checkingAccountBalance = 4000;

    double mortageLoanAmount = 350000;

     double studentLoanAmount = 75000;

      double autoLoanAmount = 35000;

       double personalLoanAmount = 5000;

     public static void main(String []args){

        

         Account account = new Account();

         int choice = 1;

         while(choice != 4){

        System.out.println("Enter 1- savings account 2-checking account 3-Loan Payment 4-exit");

         choice = account.s.nextInt();

        switch(choice){

            case 1 : account.savingsAccount(); break;

            case 2 : account.checkingAccount(); break;

            case 3 : account.loanPayment(); break;

            case 4 : System.exit(0);

            default : System.out.println("Wrong option..! try again, bye bye");

        }

        }

     }

    

     public void savingsAccount(){

        

        System.out.println("Enter 1- deposit 2-withdraw");

        int choice = s.nextInt();

        if (choice == 1 ){

            System.out.println("Enter the amount : ");

            double amount = s.nextInt();

            savingsAccountBalance += amount;

        }

        else if(choice == 2){

            System.out.println("Enter the amount : ");

            double amount = s.nextInt();

            if(amount < savingsAccountBalance){

                savingsAccountBalance -= amount;

            }

            else{

                System.out.println("No sufficient funds..! sorry transaction failed");

            }

        }

       

        System.out.println("Current Balance : " + savingsAccountBalance);

        if(savingsAccountBalance < 200){

            System.out.println("Balance is too low ..!");

        }

     }

    

     public void checkingAccount(){

         double balance = 4000;

     }

    

     public void loanPayment(){

         System.out.println("Enter 1-mortgage loan 2-student loan 3-auto loan 4-personal loan");

         int choice = s.nextInt();

         switch(choice){

             case 1 : mortageLoan(); break;

             case 2 : studentLoan(); break;

             case 3 : autoLoan(); break;

             case 4 : personalLoan(); break;

             default : System.out.println("Wrong option..! try again, bye bye"); System.exit(0);

         }

     }

    

     public void mortageLoan(){

         double monthlyPayment = 3500;

         mortageLoanAmount -= monthlyPayment;

         System.out.println("Loan Payment balance : "+mortageLoanAmount);

     }

    

     public void studentLoan(){

         double monthlyPayment = 250;

         studentLoanAmount -= monthlyPayment;

         System.out.println("Loan Payment balance : "+studentLoanAmount);

        

     }

    

     public void autoLoan(){

         double monthlyPayment = 500;

         autoLoanAmount -= monthlyPayment;

         System.out.println("Loan Payment balance : "+autoLoanAmount);

     }

    

     public void personalLoan(){

         double monthlyPayment = 1000;

         personalLoanAmount -= monthlyPayment;

         System.out.println("Loan Payment balance : "+personalLoanAmount);

     }

}

Output 1:

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

1

Enter 1- deposit

2-withdraw

1

Enter the amount : 2000

Current Balance : 6000.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

1

Enter 1- deposit

2-withdraw

1

Enter the amount : 1500

Current Balance : 7500.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

1

Enter 1- deposit

2-withdraw

2

Enter the amount : 2500

Current Balance : 5000.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

4

Output 2 :

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

2

Enter 1- deposit

2-withdraw

1

Enter the amount : 120

Current Balance : 4120.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

2

Enter 1- deposit

2-withdraw

1

Enter the amount : 40

Current Balance : 4160.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

2

Enter 1- deposit

2-withdraw

1

Enter the amount : 700

Current Balance : 4860.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

2

Enter 1- deposit

2-withdraw

1

Enter the amount : 50

Current Balance : 4910.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

2

Enter 1- deposit

2-withdraw

1

Enter the amount : 1000

Current Balance : 5910.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

4

Output 3:

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

3

Enter 1-mortgage loan

2-student loan

3-auto loan

4-personal loan

1

Loan Payment balance : 346500.0

Enter 1- savings account

2-checking account

3-Loan Payment

4-exit

4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote