Answer to Question #104522 in C++ for Dion

Question #104522
The owner of harry's car sales pays each salesperson a commission based on his or her monthly sales. Monthly sales(R) between 0-19 999.99 gets commission rate of 4%
1
Expert's answer
2020-03-05T11:12:39-0500
#include <iostream>

using namespace std;

int main()
{
    double r;
    bool b;

    do{
      b = true;
      cout << "Please enter the monthly customer sales (0-19 999.99): " << endl;
      cin >> r;
      if(!cin)//If incorrect characters are entered, then clear the input buffer and ask to enter again.
      {
        cout << "The input is not correct. Try again." << endl;
        cin.clear();
        while (cin.get() != '\n');
      }
      else
      {
        b = false;
      }
      if(!b)
      {
          if((r<0)||(r>19999.99))
          {
              cout << "The range of revenue values should be from 0 to 19999.99." << endl;
              b = true;
          }
      }
    }while(b);

    cout << "The commission for monthly sales is $" << r*0.04 <<". " << endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS