Project Java essay
COSC 1437 – LAB5 TITLE Repetition statements (Loops), Work with files – Mortgage Service. HOW TO DO EACH PART *From now and on yourLastName will be changed to your last name. *Your program should change White to your last name. *Your program should change McKINLEY WHITE to your name. *Change Mary Lane to the name of user who is using the Investment Application entered from the keyboard. *Write the file name as the first comment line at the top of the program. *After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in. *Step1: Read the requirement of each part; create the UML of data type class, write the pseudo-code of driver class in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName. *Step2: -start editor (for example eClipse) create the project with the following project name: Part 2: SU2021_LAB4PART2_yourLastName -add data type class: Part2: MortgageAccount_yourLastName -add a driver class (that contain main() Part 2: SU2021_MortgageService_yourLastName *Step3: follow step by step in the pseudo-code (or the flowchart) to write the java code in main() or driver class. *Step:4 compile and run the program. *Step5: debug if there are any errors to complete the program. LAB5 PART1 QUESTION 1: Initialize an int variable named product to 1. Write the while loop to do the following: -Display the message to ask the users to enter a number and read the number. -The number should be multiplied with product and result will be stored back to the variable product. -The loop should iterate as long as product less than 1000. -After the loop stops, display message: “product = - the while loop stops” QUESTION 2: Write a do-while loop to do the following until users enter 0 to exit. -Display the following menu: MAIN MENU 1. Option 1 2. Option 2 3. Option 3 0. Exit Type a number 1, 2, 3 to select option or 0 to exit: Read the number from the keyboard then write the switch statement: If number = 1, display the message “Do the option 1” If number = 2, display the message “Do the option 2” If number = 3, display the message “Do the option 3” If number = 0, display the message “Terminate the program” Other numbers, display the message “Invalid option.” QUESTION 3: Write a for loop that runs 12 times to display the following set of numbers: 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50 (DO NOT USE THE ARRAY IN THIS QUESTION) QUESTION 4: Write code that does the following: -Open a file named output.txt, -uses a loop to write the even numbers from 2 through 100 to the file -close the file QUESTION5: Write the code that does the following: -Declare a variable sum of int type and sum = 0 -Open the output.txt created in the question 4 -Use a loop to read all of the numbers in the file output.txt. For each number, add it to sum (sum = sum + number) -close the file -display on the screen sum = LAB5 PART2 IF YOU DO NOT HAVE THE UML and PSEUDO-CODE, YOU HAVE TO READ THE BELOW REQUIREMENT THEN CREATE UML OF DATA TYPE CLASS AND WRITE THE PSEUDO-CODE BEFORE WRITING THE CODE A bank service asks for the application that helps users to do the following tasks. After finishing each task, re-display the menu to allow users to select other tasks until users select exit to terminate the program. This program is only work for one account when it starts to end. It is only used to practice what you have just learned. File: SU2021_MortgageService_White.java so MORTGAGE SERVICE – McKINLEY WHITE ------------------------------------------------------------------- 1.Calculate the Mortgage Monthly Payment 2.Open Mortgage Account 3.Check Interest Rate of current Mortgage Account 4.Check Current Principal of current Mortgage Account 5.Process Monthly Payment 0.Exit The above requirement talks about the mortgage service. Therefore, we need to define the data type class of Mortgage account and the driver class that include main() to handle the requirement of the project. DATA TYPE CLASS Class MortgageAccount_yourLastName will handle the information of a mortgage account: account number (String), last name (String), first name (String), principal (float): principal is the total of money the account borrows from the bank. number of payments (int): only can be 360, 180. interest rate (float) -Provide no-argument constructor, parameterized constructor -Provide mutator methods, accessor methods for interestRate, principal *Provide method toString() to display the output as below: Account Number: 10216757873 Name: Lane, Mary Principal: 185000.000 Number of payments: 360 Interest Rate: 3.375% *Provide method openNewAccount() This method accepts the monthly payment as parameter. Display the following output: SU2021_MortgageService_White.java OPEN NEW ACCOUNT – McKINLEY WHITE ---------------------------------------------- Account Number: 10216757873 Name: Lane, Mary Principal: 185000.000 Number of payments: 360 Interest Rate: 3.375% Monthly Payment: 817.877 *Provide the method checkInterestRate() Display the output as below: SU2021_MortgageService_White.java CHECK INTEREST RATE – McKINLEY WHITE ---------------------------------------------- Account Number: 10216757873 Name: Lane, Mary Interest Rate: 3.375% *Provide the method checkCurrentPrincipal() -Display the following output: SU2021_MortgageService_White.java CHECK CURRENT PRINCIPAL – McKINLEY WHITE ---------------------------------------------- Account Number: 10216757873 Name: Lane, Mary Principal: 185000.000 *Provide the method processPayment() that accepts two parameters of monthly payment and payment amount and do the following: -First, calculate the interest amount: Interest amount = principal * interest Rate/100/12 -Calculate the new principal: Principal = principal – (amount paid – interest amount) -Reduce number of payments by 1: Number of payments = number of payments - 1 -Then display the output as below: SU2021_MortegageService_White.java PROCESS MONTHLY PAYMENT – McKINLEY WHITE ---------------------------------------------- Account Number: 10216757873 Name: Lane, Mary Principal: 185000.000 Number of payments: 360 Interest Rate: 3.375% Monthly Payment: 817.877 Amount you pay: 1000.000 Interest amount this month: 520.312 ---------------------------------------------- Principal: 184520.312 DRIVER CLASS The application should display the menu to allow users to select a task. After finishing one task, redisplay the menu to allow users to continue selecting another task until users want to select exit to terminate the program. File: SU2021_MortgageService_White.java so MENU OF MORTGAGE SERVICE – McKINLEY WHITE ------------------------------------------------------ 1.Calculate the Mortgage Monthly Payment 2.Open Mortgage Account 3.Check Interest Rate of current Mortgage Account 4.Check Current Principal of current Mortgage Account 5.Process Monthly Payment 0.Exit TASK1: Calculate the monthly payment -Display the message and read the following information of the customer who asks for the quote of the mortgage. The list of the information that is needed for this task is: last name (String), first name (String), amount of money asked for the mortgage (float), number of payments (int) and interest rate (float) -Call the user-defined function getMonthlyPayment() to get the monthly payment -then display the output in the following format: SU2021_MortegageService_White.java ESTIMATE MONTHLY PAYMENT – McKINLEY WHITE ---------------------------------------------- Name: Lane, Mary Principal: 185000.000 Number of payments: 360 Interest Rate: 3.375% ---------------------------------------------- Monthly Payment: 817.877 The user-define function getMonthlyPayment() will accept principal, number of payment and interest rate as parameters then apply the formula to calculate the monthly payment and return the monthly payment: MonthlyPayment = (principal * Math.pow(1 + interestRate/12, number of payments) * interestRate /12) / (Math.pow(1 + interestRate /12, number of payments)-1); TASK2: Open Mortgage Account -Asking from the keyboard and read the information of the customer who asks for opening a mortgage account about the following: last name (String), first name (String), amount to loan (float) that is called principal, number of payments (int only 360 or 180 months) and the interest rate (float) -generate the account number as a string in 10 digits. -Apply the formula to calculate the payment (see at task1) -Create the object of MortgageAccount_yourLastName, then use the object to access the method openNewAcount(monthlyPayment) of the class MortgageAccount to display the output TASK3: Check Interest Rate of current Mortgage Account If the account is not created in the task 2, display the message: “The account is not created, cannot check Interest rate.” Otherwise, using the object the MortgageAccount_yourLastName created at Task2. To access the method checkInterestRate() TASK4: Check Current Principal of current Mortgage Account. If the account is not created in the task 2, display the message: “The account is not created, cannot check Interest rate.” Otherwise, Otherwise, using the object the MortgageAccount_yourLastName created at Task2. To access the method checkCurrentPrincipal() TASK5: Process Monthly Payment If the account is not created in the task 2, display the message: “The account is not created, cannot check Interest rate.” Otherwise, do the following: -Call the function getMonthlyPayment() to have the monthly payment -Display the message and read the payment amount from the keyboard - using the object the MortgageAccount_yourLastName created at Task2 To access the method processPayment() HOW TO TURN IN THE LAB You should turn in the following files: (yourLastName should be your last name) SU2021_LAB5PART1_YourLastName.docx (part 1) UML Pseudo-code and the output pictures of part2 MortgageAccount_yourLastName.java SU2021_MortgageService_yourLastName.java MortgageAccount_yourLastName.class SU2021_MortgageService_yourLastName.class IF YOU GET ANY PROBLEM TO SUBMIT FILEs .class YOU CAN COMPRESS ALL PROJECT INTO ONE FILE .zip or .rar TO UPLOAD TO eCampus HOW TO GRADE THE LAB Items Score Turn in on time 3 PART1 Question 1 1 Question 2 1 Question 3 1 Question 4 1 Question 5 1 PART2 Submit all files requested 1 Psuedo-code(main) – UML (data type class) -output pictures 2 Data type class Define data members 1 No argument constructor – parameterized constructor 2 Method to open new account 1 Mutator Method to ask for interest rate, principal 1 Method to process payment 2 Driver class Display the menu, read task – redisplay menu 1 User-defined function getMonthlyPayment() 1 Task1: estimate monthly payment 1 Task2: Read information, Create object of MortgageAccount, access method openNewAccount() 1 Task 3: access method checkInterestRate() 1 Task 4: access method checkCurrentPrincipal() 1 Task 5: access method processPayment() 2 Compile success – qualified all the requirements 3 Write the comments – file name at the top of the file 1 Total` 30 -research paper writing service