Objectives include: Call and write methods with parameters

Objectives include:Call and write methods with parameters and return values.Use the String and Scanner classes.Use if statements to validate input and control assignments.Hand-in RequirementsAll projects and laboratories will be submitted electronically through Blackboard.Zip up your entire project directory to submit as the source.(Right click on the project folder and follow 7-Zip > Add to “project2.zip”.)The project folder should include the following two files:LoanPaymentCal.javaLoanPaymentCalOutput.txtSample OutputHere is an example of what your output should look like for a loan amount of $300000 for 2 years.Project 2 written by Steve RobbinsEnter the loan amount and loan duration in years, for exampleamount 3000 years 2[DrJava Input Box]Loan amount: $300000.00Loan period: 2 yearsLoan rate: 3.5%Monthly payment: $12960.82Month Balance Payment Remaining1 300875.00 12960.82 287914.182 288753.93 12960.82 275793.123 276597.51 12960.82 263636.704 264405.64 12960.82 251444.825 252178.20 12960.82 239217.386 239915.10 12960.82 226954.287 227616.23 12960.82 214655.428 215281.50 12960.82 202320.689 202910.78 12960.82 189949.9710 190503.99 12960.82 177543.1711 178061.00 12960.82 165100.1912 165581.73 12960.82 152620.9113 153066.06 12960.82 140105.2414 140513.88 12960.82 127553.0615 127925.09 12960.82 114964.2816 115299.59 12960.82 102338.7717 102637.26 12960.82 89676.4418 89938.00 12960.82 76977.1819 77201.70 12960.82 64240.8820 64428.25 12960.82 51467.4421 51617.55 12960.82 38656.7322 38769.48 12960.82 25808.6723 25883.94 12960.82 12923.1224 12960.82 12960.82 0.00Total payment amount: $311059.60TasksCreate a directory called project2. Write a program called LoanPaymentCal and save it in project2. The program will printProject 2 written by YOURNAMEPrompt the user for an amount and a number of years. See below for details.Print the amount and number of years.Call a method loanRate that takes an input loan amount as a parameter and returns an interest rate. If a jumbo loan (a loan amount is greater than or equal to $350,000), use 4.0%. For a large loan (not jumbo but greater than or equal to $100,000), use 3.5%. Otherwise, the interest rate is 3.0%. No print statements should be included in this method. The main method will print the loan rate.Call a method loanMonthlyPayment that will take three parameters: the loan amount, rate, and number of years. It will return a monthly payment amount. This method should not print anything. The main method should print the monthly payment.Call a method loanTotalPayment that will take 4 parameters: the loan amount, monthly payment amount, rate and the number of years. It will return the total payment amount after printing a table like the one in the sample output. The main method should then print the total payment amount.DetailsThe ScannerYou will need to use Scanner to obtain input from the keyboard. You should declare a Scanner variable named console at the beginning of your main method. Only the main method will input from the keyboard.Input FormatInputting and verifying the input data is worth 5 points (25%). When writing you program, assume that two numbers will be entered, a double value giving the loan amount and an integer giving the loan duration in years. Use the console.nextDouble() and console.nextInt() to read in the values. This will give you 1 point out of 5 for this part of the assignment. Get the rest of the assignment working before coming back to this and improve the input handling of your program.To get the maximum of 5 points on this part of the assignment, your program must accept input as 4 tokens and verify that the input is in an appropriate format.The first token will be either “amount” or “years” (without the quotes). If the first token is “amount”, the next is the amount of the loan and should be read in using console.nextDouble(). If the first token is “years”, the next token is the number of years and should be read in with console.nextInt(). If the first token was “amount”, the third token should be “years” and the number of years is read in as the fourth token using console.nextInt(). If the first token was “years”, the third token should be “amount” and the amount should be read in with console.nextDouble(). Any other tokens are considered invalid input.If invalid input is detected, the program should print an appropriate message, explaining how the input is invalid. At that point it should exit the program. You can exit the program by calling return.You can get up to 4 points by following the above description. To obtain full credit you need to also validate the numeric input before you call console.nextInt() or console.nextDouble(). You can do this using the following Scanner methods:boolean hasNextInt(): returns true if the next token is a valid int.boolean hasNextDouble(): returns true if the next token is a valid double.A typical use of these might look like this:if (!console.hasNextInt()) {System.exit(0);}int value = console.nextInt();Outputting two decimal placesUse the method twoPlaces described in Project 1 to produce numbers with 2 decimal places. Use of this is not optional in this assignment.Lining up columnsDo not use tabs to line up the columns. Instead, write a method called padOnLeft which takes 2 parameters, a String, s and an int, n. If the length of s is at least n, return s. Otherwise, return a string of length n obtained by putting the appropriate number of blanks at the front of s. You can create this string with a for loop.Use this to create the columns of your table with the decimal points in each column lined up.Calculating monthly paymentGiven a loan amount, b, an monthly interest rate, r, and a loan period in months, n, you can compute monthly payment, p, using the following formula:p = b * r1 – (1+r)-nCalculating loan balanceWhen you take out a loan, you are charged interest monthly based on an annual interest rate. If the annual rate is r, the monthly rate is r/12. The annual rate is usually represented as a fraction, a number between 0 and 1, but the interest rate will be entered as a percentage. If the annual interest rate is 15%, the annual rate will be 15/100 = .15.If the balance at the beginning of the month is b, the balance at the end of the month before a payment is made is b + b*r/12. After the payment is made, the balance is reduced by the payment.Test the program with the inputs shown in the sample output above and make sure your program produces the correct values. You can use tabs to line up the columsn while debugging, but in the final program you should use the padOnLeft method described above.When you think your program is working correctly, test the program with an amount of $10000 for 2 years. Save the output to a file called LoanPaymentCalOutput.txt in the project2 directory.Rubric[5 Points] For the main method data input and output. See the details of the assignment.[3 Points] If your program has a method loanRate() that takes a parameter and returns a rate correctly.[2 Points] If your program has a method loanMonthlyPayment() that takes parameters and returns a monthly payment amount correctly.[3 Points] If your program has a method loanTotalPayment() that takes parameters and returns a total payment amount correctly.[3 Points] If the method loanTotalPayment() prints month, monthly principle, payment and remaining information per month correctly including with two decimal places and in appropriate columns.[4 Points] One point for each of the following:If the main method of your program prints “Project 2 written by […]” and calls the three other methods.If your submission was a Zip file named project2.zip containing two files called LoanPaymentCal.java and LoanPaymentCalOutput.txt.If your program contains a comment that describes what the program does and contains a descriptive comment for each method.If your program is indented properly.

 

CLICK HERE TO ORDER A SIMILAR PAPER

We pride ourselves in writing quality essays

CLICK HERE TO CONTACT US

Lets Start Working

Plagiarism Free

We use anti-plagiarism software to ensure you get high-quality, unique papers. Besides, our writers have a zero plagiarism mentality

On Time Delivery

Your essay will be delivered strictly within the deadline.  If you have an urgent order, we can do it!

Money Back Guarantee

We offer warranty service, including free revisions, and a right to request a refund incase your expectations are not met!

THE BEST PAPER WRITER HELPER

Our Advantage

  • Say “NO” to plagiarism – FREE plagiarism report as an addition to your paper
  • The lowest prices that fit excellent quality
  • Authorship – you are the one who possesses the paper. We DO NOT re-sale or re-use any of them.

OUR PAPER WRITER HELPER GOODIES

Our Freebies

  • Free Cover Page
  • Free Revisions
  • Free Reference Page
  • Free 24/7 support

Pin It on Pinterest

Share This