Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Math 130 Thank you Lovel1 Carnell - Math 130-603 - Instructor: Professor Mimi Rasky - February 10, 2023 - JavaProject.1 package project_1; import java.uti1.* public

Math 130

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Thank you

Lovel1 Carnell - Math 130-603 - Instructor: Professor Mimi Rasky - February 10, 2023 - JavaProject.1 package project_1; import java.uti1.* public class project_ 1 a public static vold main (String [] args) 1 If user input Scanner scan = new Scanner (System. in); double currentBalance; double paymentmade; int daysbefore; double annualinterest; double monthlyInterest; double x,y,z; double average; double interest: double principalpart; double endingBalance; System.out.print ("Enter current balance in dollars and cents: "); currentBalance = scan. nextDouble (): System.out.print ("Enter the payment made in dollars and cents: "); paymentmade = scan. nextDouble () ; System, out.print ("Enter the days before statement date: "); daysbefore = scan. nextInt () ; System. out.print ("Enter annual interest rate in percent form (ex: 8.75): "); annualinterest = scan. nextDouble (); System. out. print In () : scan.close (): /f calculations monthlyInterest = (annualinterest /100)/12; x= currentBalance * 31 ; y= paymentmade * daysbefore; z=xy; average =2/31; interest = (average) (monthlyInterest) principalpart = paymentmade - interest; endingBalance = currentBalance - principalPart; If output System. out.printf (" 846s120.2f8g, "Annual interest rate: ", annualinterest): System. out. printf ("849s 20.2f(n"," "Beginning Balance: \$", currentBalance); System.out.printf("g46s\$23d", "Number of days payment made before statement: ", daysbefore); System. out.printf("\$49s\$20.2f", "Average Daily Balance: \( \$ " \)quot;quot;, average); System. out.printf (" 499820.2f", "Amount applied to principal: \$", principalpart); System. out.printf ("849a\$20.2fln", "Amount applled to interest: \$", interest); System. out.printf ("349s\$20.2fln", "Ending Balance: \( \$ " \), endingBalance); You will modify your previous Java program called Project1. Call this new assignment Project2. Modify the program you created in the previous assignment in the following ways: 1) Your program should let the user enter data for a series of credit card statements rather than just one at a time. You will declare a new int variable called counter to keep track of how many credit card statements have been processed. For each, the program will accept all of the data and display the result. When the user has finished entering the last credit card's data and observed the result, the user should enter 0 for current balance as a code (aka sentinel) to "quit." This should then cause the program to display the total number of credit card statements processed (i.e. your counter variable) and then terminate. Use a while loop in your program, and not a do-while loop in order to get credit. 2.) The credit card user's payment may be more than the amount needed to pay off the balance left on the card. If that happens in a particular case, the ending balance would be negative. Add some code to your program that would deal with such a case (i.e. it will do the following if and only if the monthly payment entered is a value larger than the current balance) as follows: Insert an if statement (not an if-else statement) AFTER all of the usual calculations (already specified in JavaProject1) have been done - with the following lines (ONLY!) in the if statement's body: (a) The payment is adjusted so it exactly pays off the loan (i.e. payment = current balance + interest amount) (b) The amount applied to the principal is recalculated. It will now be exactly equal to the current balance, so: principal Part = current balance (c) The ending balance is recalculated and set to zero. (i.e. ending balance = zero). If I see more lines than this inside of the body of this if statement, you will lose points. 3.) Use permanent named constants to represent the following four (4) values: (a) ZERO (0) (b) the number of months in a year (12) (c) the factor needed to convert interest in percent to interest in decimal (i.e., 100) (d) the number of days in a typical billing cycle: 31 . Your program should contain none of these literal numeric constants. In other words, your program will always refer to these constants by their declared name. Remember that you need to use the keyword "f inal" when you declare a permanent constant, Also, by tradition, permanent constants are named using all CAPITAL LETTERS. As an example: finalintMONTHS=12; 4.) Declare String variables for each and every string used in this assignment. As an example: String curBalprompt = "Enter current balance in dollars and cents: " ; Sample Run Enter current balance in dollars and cents: 2268.62 Enter the payment made in dollars and cents: 750.00 Enter the days before statement date: 7 Enter annual interest rate in percent form (ex: 8.75): 24.90 Annual interest rate: 24.90 Beginning Balance: \$ $2268.62 Amount of payment: $750.00 Enter current balance in dollars and cents: 29854.49 Enter the payment made in dollars and cents: 654.67 Enter the days before statement date: 2 Enter annual interest rate in percent form (ex: 8.75): 13.9 Annual interest rate: 13.90 Beginning Balance: \$ 29854.49 Amount of payment: \$ 654.67 Enter current balance in dollars and cents: 123.35 Enter the payment made in dollars and cents: 150.00 Enter the days before statement date: 4 Enter annual interest rate in percent form (ex: 8.75): 25.31 Annual interest rate: 25.31% Beginning Balance: \$ 123.35 Amount of payment: \$ 125.54 Amount applied to principal: \$ 123.35 Amountappliedtointerest:Endingbalance:$$2.190.00 Enter current balance in dollars and cents: 0 Number of credit card statements processed

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

6. What questions would you suggest should be included?

Answered: 1 week ago