Skip to main content
GameDev.net gamedev.net
🔒 Locked

java question

Started by SuperHappyFunMan Sep 24, 2000 at 2:48 PM 0 replies 400+ views
Original Post
SuperHappyFunMan
SuperHappyFunMan
Im not sure if this is the right place to post this, if it isnt I apologize: Im working on a program for class, heres the description: Loan Repayment Problem, a Java application This assignment will require you to write a full program. It includes loops, arithmetic expressions, the use of the double primitive data type and interactive input/output. Name this class Loan and make sure the file is named Loan.java. You are planning to buy a car. You need to borrow L dollars from a bank. You plan to make a monthly payment of P dollars every month. Part of the monthly payment is the interest, calculated as i% of the current unpaid balance. The rest of the payment is applied toward the unpaid balance. Write a program that determines the following information: The number of monthly payments required to repay the entire loan The amount of the last payment. It will probably be less than P. Then the program should prompt the user to enter a month m and determine the following information: The amount of interest paid in month m The amount of money applied toward the unpaid balance that month The cumulative amount of interest that has been paid at the end of that month The amount of loan that is still unpaid at the end of that month The program should keep prompting until the user enters 0 as the month. -------------------------------------------------------------------------------- Example program run/execution: Your output should be exactly the same as the example output shown below (including blank lines) with the exception of the actual numerical values. C:\TEMP> javac Loan.java C:\TEMP> java Loan (this is a BLANK line) WELCOME TO LOAN CALCULATOR (this is a BLANK line) Enter the decimal $$ amount of initial loan : 40000 Enter the decimal $$ amount of monthly payment: 2000 Enter the decimal % rate of monthly interest : 1 The total number of monthly payments is : 23 The payment for the last month is : 853.9170642511747 (this is a BLANK line) (this is a BLANK line) Enter the month for detailed information: 24 (this is a BLANK line) Error: You loan will be paid off by 23 months. Please enter a number between 0 and 23 (inclusive). (this is a BLANK line) Enter the month for detailed information: 23 (this is a BLANK line) The detailed information for this month is as follows: Amount of interest paid : 8.454624398526482 Amount paid toward unpaid balance : 845.4624398526482 Cumulative amount of interest paid: 4853.917064251174 Amount of loan unpaid : 0.0 (this is a BLANK line) (this is a BLANK line) Enter the month for detailed information: 22 (this is a BLANK line) The detailed information for this month is as follows: Amount of interest paid : 28.172895444085626 Amount paid toward unpaid balance : 1971.8271045559143 Cumulative amount of interest paid: 4845.462439852648 Amount of loan unpaid : 845.4624398526482 (this is a BLANK line) (this is a BLANK line) Enter the month for detailed information: 21 (this is a BLANK line) The detailed information for this month is as follows: Amount of interest paid : 47.69593608325309 Amount paid toward unpaid balance : 1952.3040639167468 Cumulative amount of interest paid: 4817.289544408562 Amount of loan unpaid : 2817.2895444085625 (this is a BLANK line) (this is a BLANK line) Enter the month for detailed information: 20 (this is a BLANK line) The detailed information for this month is as follows: Amount of interest paid : 67.02567929034959 Amount paid toward unpaid balance : 1932.9743207096503 Cumulative amount of interest paid: 4769.593608325308 Amount of loan unpaid : 4769.593608325309 (this is a BLANK line) (this is a BLANK line) Enter the month for detailed information: 0 C:\TEMP> I''ve gotten a good portion of it done, but im stuck on how to get the detailed info per month, i know how to use if/else type statements to do it but I cant figure a formula to calculate intrest paid or so forth for a certain month, can anyone help please thank you.
SPAR
SPAR
what does that have to do with game development?

you can get input with
thenumber = JOptionPane.showDialogInput( "Please enter the number: ");
and convert it to an int with something like
myint = Int.parseInt( thenumber);

email me with a specific question and i will answer it

also read the chapter!!!!!!!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.