Stuck with a do while loop. need help please!

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
Last edited on
:OOOO
You probably shouldn't be reading the sales amount in the loop, as you only want to ask the user for that once.

Line 27 doesn't do anything; did you mean += to actually change rate?
Topic archived. No new replies allowed.