Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 06-09-2005, 02:48 PM   #1 (permalink)
simplex85
Registered User
 
Join Date: Jun 2005
Posts: 1
simplex85 is on a distinguished road
GAH!! how do i do total interest with while loops???? help me please =(

This is the code i have so far and i am dying on trying to find out how i can come up with the total interest paid with no user input.

I believe i have to come up with a second while loop after the section i marked in green. which i found out to be 24 months. But after that, i'm not sure how many statements i need and when i do do it i come up with some rediculous small number like -$0.03.

Code:
**************************************
#include <iostream>
using namespace std;
int main()

{
	double totalInterestPay;
	double debt = 1000.00;
	int count = 0;

		cout<< "This program will calculate the amount\n"
		<< "of months it will take for you to pay off your debt\n"
		<< "with a debt of $1000 and an annual\n"
		<< "interest rate of 18% at 1.5% per month.\n";

	while (debt > 0.00)
	
	{
		debt = debt * 0.015 + debt - 50;
		count++;

	}
	
		cout.setf(ios::fixed);
		cout.setf(ios::showpoint);
		cout.precision(2);


	cout<< endl << "Your debt will be paid off after " 
		<< count << " months.\n";
	cout<< endl<< "your total interst paid throughout\n"
		<< "the course of the loan is $"<< totalInterestPay 
		<< endl;

	

	return 0;

}

Last edited by redhead; 06-09-2005 at 11:23 PM. Reason: Added [code][/code] tags
simplex85 is offline   Reply With Quote
Old 06-09-2005, 11:32 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
You don't have to come up with another loop, just put the calculations of total payment in the loop, where you calculate the month needed to payoff the debt.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
total newb question-loops cjsmith22 Standard C, C++ 2 05-28-2005 08:37 AM
Help on interest program B00tleg Standard C, C++ 2 10-07-2004 08:50 PM


All times are GMT -8. The time now is 11:48 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting