#include <iostream>
#include<limits>
using namespace std;
 
void countTheSalary(float hours, float miles){
    float salaryWithVAT;
    float salaryWithoutVAT;
    
    if(hours < 10){
        salaryWithVAT = (((hours * 20) + 50) + (miles * 3)) * 0.2;
        salaryWithoutVAT = ((hours * 20) + 50) + (miles * 3);
        cout << "According to your data, salary with VAT will be: " << salaryWithVAT << " and salary without will be: " << salaryWithoutVAT << endl;
    }else{
        salaryWithVAT = ((hours * 20)+ (miles * 3)) * 0.2;
        salaryWithoutVAT = (hours * 20) + (miles * 3);
        cout << "According to your data, salary with VAT will be: " << salaryWithVAT << " and salary without will be: " << salaryWithoutVAT << endl;
    }
    
}
int main() {
    float theHours;
    float theMiles;
    
    cout << "Please enter the number of hours (it should be a positive number): " << endl;
    cin >> theHours;
    cout << "Please enter the number of miles (it should be a positive number): " << endl;
    cin >> theMiles; 
   
    while(1){
            if(cin.fail()){
                cin.clear();
                cin.ignore(numeric_limits<streamsize>::max(),'\n');
                cout<< "You have entered wrong input.WAIT FOR A FEW SECONDS THEN ENTER AGAIN" <<endl;
                cout << "Please enter the number of hours (it should be a positive number): " << endl;
                cin >> theHours;
                cout << "Please enter the number of miles (it should be a positive number): " << endl;
                cin >> theMiles;
            }
            if(!cin.fail())
                break;
    }
    countTheSalary(theHours, theMiles);
    return 0;
}
Comments