Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Java, I have to modify the code For the loan payments, the user is to choose whether the loan is for a mortgage, a

In Java, I have to modify the code

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.

This is the code I have to modify:

package virtualatm; import javax.swing.JOptionPane; public class VirtualATM { public static void main(String[] args) { //items and balances int SaveBalance=4000; int CheckBalance=4000; int MortBalance = 0, StudBalance = 0, AutoBalance = 0, PersBalance = 0; int pas, wid, dep; int num; int Snum, Swid, Sdep = 0; int Cnum, Cwid = 0, Cdep; int Lnum; int back; int pass = 0; //welcome to atm JOptionPane.showMessageDialog(null, "Welcome to My ATM","ATM", JOptionPane.INFORMATION_MESSAGE); //pin pass=Integer.parseInt(JOptionPane.showInputDialog(null, "Please Enter Your Four Digit Pin","ATM", JOptionPane.QUESTION_MESSAGE)); //input pin if ( pass < 10000 && pass > 0000){ //if pin is correct do{ //choose account String f=JOptionPane.showInputDialog(null,"Please Choose Your Account "+"[1] Checking Account " +"[2] Savings Account "+"[3] Loans ", "MyBank",JOptionPane.QUESTION_MESSAGE); num=Integer.parseInt(f); switch(num){ //Checking account case 1: String g=JOptionPane.showInputDialog(null,"Please Choose Your Transaction "+"[1] Check Balance " +"[2] Withdraw "+"[3] Deposit ", "MyBank",JOptionPane.QUESTION_MESSAGE); Cnum=Integer.parseInt(g); if (Cnum==1){ JOptionPane.showMessageDialog(null,"Your Balance is "+CheckBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); } if (Cnum==2){ Cwid=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Withdraw " ,"ATM",JOptionPane.INFORMATION_MESSAGE)); if(CheckBalance==200){ JOptionPane.showMessageDialog(null,"Your Balance is below 200","ATM",JOptionPane.ERROR_MESSAGE);} if (Cwid>CheckBalance){ JOptionPane.showMessageDialog(null,"Insufficient Funds!","ATM",JOptionPane.ERROR_MESSAGE); } CheckBalance=CheckBalance-Cwid; JOptionPane.showMessageDialog(null,"Please collect your money"+" "+"Your Remaining Balance is"+CheckBalance,"ATM",JOptionPane.INFORMATION_MESSAGE); if(CheckBalance<200){ JOptionPane.showMessageDialog(null,"Your Balance is below 200.Please maintain minimum balance","ATM",JOptionPane.ERROR_MESSAGE);} } if (Cnum == 3){ Cdep=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Deposit ", "ATM",JOptionPane.INFORMATION_MESSAGE)); CheckBalance=Cdep+CheckBalance; JOptionPane.showMessageDialog(null,"Your Current Balance is"+CheckBalance,"ATM",JOptionPane.INFORMATION_MESSAGE); } break; //Savings account case 2: String h=JOptionPane.showInputDialog(null,"Please Choose Your Transaction "+"[1] Check Balance " +"[2] Withdraw "+"[3] Deposit ", "MyBank",JOptionPane.QUESTION_MESSAGE); Snum=Integer.parseInt(h); if (Snum==1){ JOptionPane.showMessageDialog(null,"Your Balance is "+SaveBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); } if (Snum==2){ Swid=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Withdraw " ,"ATM",JOptionPane.INFORMATION_MESSAGE)); if (Swid>SaveBalance){ JOptionPane.showMessageDialog(null,"Insufficient Funds!","ATM",JOptionPane.ERROR_MESSAGE); } else{ SaveBalance=CheckBalance-Swid; JOptionPane.showMessageDialog(null,"Your Remaining Balance is"+SaveBalance,"ATM",JOptionPane.INFORMATION_MESSAGE); } if (Snum == 3){ dep=Integer.parseInt(JOptionPane.showInputDialog(null,"Please Enter Amount to Deposit ", "ATM",JOptionPane.INFORMATION_MESSAGE)); SaveBalance=Sdep+SaveBalance; JOptionPane.showMessageDialog(null,"Your Current Balance is"+SaveBalance,"ATM",JOptionPane.INFORMATION_MESSAGE); } } break; //Loans case 3: String i=JOptionPane.showInputDialog(null,"Please Choose the Loan you would like to make a payment on "+"[1] Mortgage " +"[2] Student Loan "+"[3] Auto Loan " + "[4] Personal Loan ", "MyBank",JOptionPane.QUESTION_MESSAGE); Lnum=Integer.parseInt(i); if (Lnum==1) { JOptionPane.showMessageDialog(null,"Your Current Balance is "+MortBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); MortBalance=MortBalance-3500; JOptionPane.showMessageDialog(null,"Your remaing Mortgage loan is "+Math.abs(MortBalance),"ATM",JOptionPane.INFORMATION_MESSAGE); } if (Lnum==2) { JOptionPane.showMessageDialog(null,"Your Current Balance is "+StudBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); StudBalance=StudBalance-250; JOptionPane.showMessageDialog(null,"Your Student loan have to be paid is"+Math.abs(StudBalance),"ATM",JOptionPane.INFORMATION_MESSAGE); } if (Lnum==3) { JOptionPane.showMessageDialog(null,"Your Current Balance is "+AutoBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); AutoBalance=AutoBalance-500; JOptionPane.showMessageDialog(null,"Your Auto loan have to paid is "+Math.abs(AutoBalance),"ATM",JOptionPane.INFORMATION_MESSAGE); } if (Lnum==4) { JOptionPane.showMessageDialog(null,"Your Current Balance is "+PersBalance+" dollars","ATM",JOptionPane.INFORMATION_MESSAGE); PersBalance=PersBalance-1000; JOptionPane.showMessageDialog(null,"Your Personal loan have to be paid is "+Math.abs(PersBalance),"ATM",JOptionPane.INFORMATION_MESSAGE); } break; default:System.exit(0); } //Return to top back=JOptionPane.showConfirmDialog(null,"Would you like to make another transaction","ATM",JOptionPane.YES_NO_OPTION); } while(back==0); } //End if //incorrect pin else{ JOptionPane.showMessageDialog(null,"Please re-enter PIN","Incorrect PIN",JOptionPane.ERROR_MESSAGE); } }}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions