stuck on 1 problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Includes
#include "stdafx.h"
#include <iostream>
#include <conio.h>
using namespace std;

// Main Function
int main()
{
	int year;
	int charge;
	float percent;
	double totalamt;

	cout << "This program will display projected rates for the next six years.\n\n";

	cout << "Enter the yearly charge of the country club: $";
	cin >> charge;
	cout << "Enter the percentage fee for each year (ex. 4% = .04): ";
	cin >> percent;

	cout.setf(ios_base::fixed, ios_base::floatfield);
	cout.precision(2);

	cout << "\n\n";

	cout << "Year and Total Amount" << endl;

	for (year = 1; year <= 6; year++)
	{
		totalamt = (charge * percent) + charge;
		cout << year << " = " << totalamt << endl;
	}
	_getch();

	return 0;
}


I am having trouble, everything seems ok, but i for some reason cannot get the fee percent charge to add every year. When i run the program all the amounts are
$2600, it suppose to add the percent fee every year for the next 6 years.

Can anyone else see what im doing wrong, i cant figure it out.
in your for loop,

totalamt += (charge * (percent/100)) + charge;

The way you had it, totalamt stayed the same each time since nothing was incrementing or adding to the current total.
Last edited on
thank you it worked.
Topic archived. No new replies allowed.