Answer to Question #143930 in C++ for Walid

Question #143930
A builder needs a app developed that will support them in pricing up a job. The parameters that affect the job are:
The hourly rate (£20 per hour)
Distance to job (£3 per mile)
Overall material cost
If the job is less than 10 hours add an additional £50, for example, a 9 hour job would be (9X20) + 50
You will need to show the job with and without VAT (additional 20% of total job cost)
Don’t forget data validation
1
Expert's answer
2020-11-12T14:23:13-0500
#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;
}

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