#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;
}
Comments
Leave a comment