Needs help in logic

Hi guys: Program display each salesperson's commission. The commission is calculated by xplying the sales person's sales by 10%. My code is not working correctly needs help.

using namespace std;
int main()
      double sales = 0.00;
      double commission = 0.00;
      cout << "Enter a sales amount==>";
      cin >> sales;
      while (sales > 0.0)
            commission = sales * .1;
            cout << commission << endl;

      return 0;
Who is Participating?
AriMcConnect With a Mentor Commented:
Replace this

   while (sales > 0.0)


   if (sales > 0.0)

mustish1Author Commented:
I'm assuming you put the while loop in there for error checking. This is good and it should be in there. Since this is quite clearly an academic exercise (homework or learning on your own), I won't give direct answers. However, I think you want something like

while (sales < 0)
  cout error and ask again;
  get the input again;
Now do the calculation outside the loop;
And display it;
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.