Solved

Needs help in logic

Posted on 2011-02-12
3
369 Views
Last Modified: 2012-05-11
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.

#include<iostream>
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;
       }

      system("pause");
      return 0;
}
0
Comment
Question by:mustish1
3 Comments
 
LVL 9

Accepted Solution

by:
AriMc earned 500 total points
ID: 34879125
Replace this

   while (sales > 0.0)

with

   if (sales > 0.0)

0
 

Author Closing Comment

by:mustish1
ID: 34879143
Thanks.
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34879153
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;
 
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now