How many cents are in a dollar? 1 is 1 cent. 100 is 100 cents, or 1 dollar. 1000 is 10 dollars. Etc.
Viggy
Printable View
To recreate it put
at the end of the loop in calculate.Code:Payment=Total*MinInterest;
The reason for this is to reset the minimum payment for each month. If you also add
The code does not actually get stuck the decimal points just keep getting longer. I just do not know how to fix this. I have searched for trimming double on goggle but found nothing. My problem is I do not understand how to do it. My incompetence is the problem. Just asking how is the correct way to do this. :)Code:cout<<Payment<<" "<<month<<endl;
system("PAUSE");
I will work on changing over the code tonight. I can see there needs to be exception handling going on just in case the user tries to enter cents(157.03). I know I also need to add exception handlers for invalid input but my main focus was just practice for the basic equation and to get better with my code. I know college will help polish me and make me "think outside the box", but I want to get ahead for better grades and understanding.
I am not talking about differences in months length (28..31 days).
My point is that what you call AverageDailyBalance is NOT an average daily balance. It is about 30 times less, which makes your interest negligible. You are practically paying down the principal only. But since you do not check for the overpayment on the last month, your calculations result in 34 payments (33 * $150 is $4,950, which is less that your initial amount), whatever the interest is.
While I have so many peoples attention can I ask what would benefit me the most to study? My main concentration is going to be Java in my associates degree then it moves to c++ introduction at the end. The bachelors goes more in depth with c++ and implementation. I know a lot of you have probably been through all this. So what did you have the hardest time on and what do you wish you would have had previous experience with?
I have been watching MIT lectures at acadimicearth.org. As well as videos from
The University of Whales. Very good videos for beginners and a heads up for college. I am self taught so far and these videos are all the learning I have done. I have some O'Reilly books but that is it. Going to band practice, I will check the posts when I get back.
Usually, this is not a case for writing an exception handler in C++. Making a typing mistake is not an "exceptional" condition. It happens all the time.
I know in Java and other languages, they throw exceptions for any little thing that could go wrong. In the C++ world, this usage of exceptions is rarely done. If the code is guaranteed to do something based on a condition, and the guarantee cannot be met due to some circumstance, then that would be a case for exception handling.
For example, an important file missing when it must (not should, but must) be there on the system, or expanding an array to a certain size and it fails due to lack of memory, etc. these would be considered exceptional conditions. Someone with fat fingers typing a number and hitting enter doesn't fit this, IMO.
Regards,
Paul McKenzie
Not really using a book. More like watching lectures. I understand c++ is all about object or classes. I do need to do this and will be a lot more comfortable with it after I start working on java. I should implement classes and objects now. Is that what you are recommending?
You should separate the input and output format from the internal storage format. Even if you're counting cents internally (so that $157.03 becomes 15703 cents), that doesn't mean that you shouldn't be able to accept "157.03" as an input in dollars. You validate the input, then you convert it to your internal format. Similarly, you can convert your count of cents back to the conventional notation on ouput:
Code:void outputmoney(ostream &out, int totalcents)
{
int dollars = totalcents/100;
int cents = totalcents%100;
out << "$" << dollars << "." << cents;
}
outputmoney(cout, 15703); // test call