Results 1 to 8 of 8
Thread: Clueless as to what is wrong.
- 09-22-2012, 11:53 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
Clueless as to what is wrong.
I have written some code to "print out three lines for each loan, giving the amount of monthly payments, the interest paid over the life of the loans, and the total amount paid back over the life of the loan, with appropriate wording."
I was given a formula to figure out the monthly payment and I get the monthly payment that is given so I know for a fact that the formula in my code is right. But the problem is somewhere where I calculate the interest and total amount paid.
When you run the program, these numbers should be typed in:Java Code:import java.io.*; import java.util.*; public class Interest { { Scanner Console = new Scanner(System.in); System.out.print("The amount I wish to borrow: "); double Borrowed = Console.nextDouble(); System.out.print("The loan rate I can get is: "); double Rate = Console.nextDouble(); System.out.print("The number of months it will take me to pay off the loan is: "); double Month = Console.nextDouble(); double MP = Borrowed * (Rate/1200.0) * Math.pow(1+Rate/1200.0,Month)/(Math.pow(1+Rate/1200.0,Month)-1); System.out.println(" "); double newMP = Math.round(MP*100.0)/100.0; System.out.println("The monthly payment will be: " + newMP); double totalinterest = (newMP*Month)-Borrowed; double newtotalinterest = Math.round(totalinterest*100.0)/100.0; System.out.println("The total amount of interest paid is: " + newtotalinterest); double Totalpaid = newMP*Month; System.out.println("The total amount paid is: " + Totalpaid);
The amount I wish to borrow is? 7500
The loan rate I can get is? 14.5
The number of months it will take me to pay off the loan is? 36
The numbers you should be getting are:
My monthly payments will be $ 258.16
Total Interest Paid is $ 1793.66
Total Amount paid is $ 9293.66
My monthly payment number is the same as the one given but my Total Interest paid and Amount paid are off by 10 cents. I have been thinking about this problem all day and can not find a solution. It is probably staring me right in the face but can anyone LEAD me in the right direction?
- 09-23-2012, 01:01 PM #2
Member
- Join Date
- Sep 2012
- Posts
- 26
- Rep Power
- 0
Re: Clueless as to what is wrong.
First of all statements can only be executed in methods.
- 09-23-2012, 02:01 PM #3
Re: Clueless as to what is wrong.
Please go through the Forum Rules -- particularly the third paragraph.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: Clueless as to what is wrong.
If you're not using an IDE to create your programs, you'll want to compile your code early and often and making sure to fix any compilation errors before trying to add new code. That would have saved you a lot of trouble here in your program above.
- 09-24-2012, 01:03 AM #5
Member
- Join Date
- Sep 2012
- Posts
- 2
- Rep Power
- 0
- 09-24-2012, 01:51 AM #6
-
Re: Clueless as to what is wrong.
No, the code you've posted won't even compile, since as pointed out, you've got statements sitting out naked in the class when they should be within a main method (which the class doesn't even have). If you have different code that's actually compiling and running, and if you're still having problems, then you'll want to post the new code and not waste our time with code that doesn't reflect the current problem and that doesn't run.
- 09-24-2012, 05:47 AM #8
Member
- Join Date
- Sep 2012
- Posts
- 68
- Rep Power
- 0
Similar Threads
-
I can't find anything wrong with this but somehow it's wrong.
By Biscuit Tickler in forum New To JavaReplies: 2Last Post: 09-12-2012, 09:28 PM -
What am I doing wrong here?
By fatabass in forum New To JavaReplies: 3Last Post: 01-21-2012, 09:45 PM -
Im clueless, please help
By truant420 in forum New To JavaReplies: 14Last Post: 03-02-2011, 12:59 AM -
What am I doing wrong?
By yankeefan9874 in forum New To JavaReplies: 1Last Post: 04-16-2010, 08:54 AM -
Wrong output (well.. the one who's wrong is probably me ;) )
By shacht1 in forum New To JavaReplies: 2Last Post: 11-22-2009, 03:48 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks