Solved

Needs help in logic

Posted on 2011-02-12
3
373 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto-indent certain lines in Notepad++ 10 168
VB.net and sql server 4 64
Output in PHP throwing alignment of data off issue 12 68
C++ statement T∗ begin(Vector<T>& x) 5 38
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.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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