reassign 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
#include "stdafx.h"
#include <iostream>
using namespace std;

int main(double total)
{
	float charge , fee;

	cout << "This displays the membership increse for the next 6 years.\n\n";

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

	cout << "Enter membership charge: $";
	cin >> charge;
	cout << "Enter membership fee percent in decimal form: ";
	cin >> fee;

	cout << "\n\n";

	for (int x = 1 ; x <= 6 ; x++)
	{
		total = (charge * fee) + charge;
		cout << x << " = " << total;
		cout << endl;
	}
	
	cout << endl << "Press ENTER to exit...";
	cin.clear();
	cin.sync();
	cin.get();

	return 0;
}


I always seem to have trouble with these type of problems.

When the user enter a membership charge and a fee in decimal form, so if the
user enters 2500 as charge and .04 as fee, the total needs to go up for every year, so 2500 and .04 would be

year 1 2600

then year 2 should start at 2600 then go up.

im having trouble getting the year 2 to start at the total of year one, etc all the way up to year 6.

let me know if i need to explain it better, im not a very good speaker, when it comes to explaining a problem.
int main(double total)

This seems weird. The normal convention for program arguments is :

main(int argc, char *argv[])

Does that compile?

Apart from that, you assign a value to total, so having it as a program argument is pointless.

If you don't need program arguments then just do this:

1
2
3
4
5
6
int main() {

//your code here

return 0;
}


Edit: I just realised you did the same thing in your other thread.
Last edited on
yeah i just moved that down i had to make it a double total = 0 in order for it to work, but i still need the total problem fixed.

example:

the users enters 2500 and .04

it should display
1 = total

but then i need the total to pick up from year 1 and do the process again all the way to year 6, when i run this program now i get 2600 for every year, judging by the way this is going the correct result should be.

1 = 2600
2 = 2700
3 = 2800
4 = 2900
5 = 3000
6 = 3100

but i get

1 = 2600
2 = 2600
3 = 2600
4 = 2600
5 = 2600
6 = 2600

my output is wrong.
You're not increasing charge year over year.
In subsequent years you're calculating from the original value of charge.

Forget total. Line 23 chould read:
1
2
charge = (charge * fee) + charge;
cout << x << " = " << charge;



Last edited on
ok now, the last one is the sort student line up i posted in another topic.

I hadd all these done but my harddrive failed and i forgot how i did it.
Dog ate the hard drive?
Topic archived. No new replies allowed.