I need help with a do while!

Alright I have a program that needs to calculate different rates of commission for a particular sale

I'm stuck in a loop and I'm not sure how to update the final cout statements as well.

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
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	//declare variables
	
	double sales = 0.0;
	double commission = 0.0;
	double rate =.05;
	

	//set up do while loop
	
	do {
		
		
		
		cout << "Enter the sales amount: $";
		cin >> sales;
      
		//calculation
		commission = sales * rate;

		//set increment to increase by one each time
		rate+.05;

		cout << rate * 100 << "% commission: $" << commission << endl;

	} while (rate <= .25);//end while at last bracket

system ("pause");
return 0; 
}//end main 


The program should look like this at the end

Enter the sales: 25000
10% commission: $2500
15% commission: $3750
20% commission: $5000
25% commission: $6250
Press any key to continue..._

and yes those are the actual rates i need to calculate and they are in increments of 5%

Thanks to whoever replies ;O
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
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	//declare variables
	
	double sales = 0.0;
	double commission = 0.0;
	double rate =.10;
	

	//set up do while loop

		cout << "Enter the sales amount: $";
		cin >> sales;
	
	do {
		//calculation
		commission = sales * rate;

		//set increment to increase by one each time
		

		cout << rate * 100 << "% commission: $" << commission << endl;
		rate = rate +.05;
	} while (rate <= .25);//end while at last bracket

system ("pause");
return 0; 
}
I did and there's no difference. The program will calculate and display the 10% commission but that one only
It should be like this.
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
#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	//declare variables
	
	double sales = 0.0;
	double commission = 0.0;
	double rate =.1;
	

	//set up do while loop
	cout << "Enter the sales amount: $";
		cin >> sales;
	do {
		
		
      
		//calculation
		commission = sales * rate;

		//set increment to increase by one each time
		rate = rate +.05;

		cout << rate * 100 << "% commission: $" << commission << endl;

	} 
	while (rate <= .25);//end while at last bracket

return 0; 
}
THANK YOU.

however i did have to change the double rate to .05 instead of .1 but it works perfectly! Here's the final product.

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 <iostream>
#include <cmath>
using namespace std;

int main()
{
	//declare variables
	double sales = 0.0;
	double commission = 0.0;
	double rate =.05;
	

	//ask for sales amount
	cout << "Enter the sales amount: $";
	cin >> sales;

	//set up do while loop
	do {
      
		//calculation
		commission = sales * rate;
		
		//set increment to increase by one each time
		rate = rate + 0.05;

		//display commission
		cout << rate * 100 << "% commission: $" << commission << endl;
	
		
	} while (rate <= .25);//end while at last bracket

system ("pause");
return 0; 
}//end main 


Once again, thank you. I was stuck on that for a while.
Topic archived. No new replies allowed.