Question

C++ program

Please only (if) (else) statements No while statements use Write a program that takes rate and outputs the employees wages f

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
double CalculateHourlySalary(int hrRate, int hours);
int main(){
   double hrRate,hours;
   cout<<"       Employee's wage calculator\n"<<endl;
   cout<<"Enter Employee's Hours Worked: ";
   cin>>hours;
   cout<<"Enter Regular Pay Rate:$ ";
   cin>>hrRate;
   if(hours<0)   
      cout<<"Hours = "<<hours<<" is invalid"<<endl;
   if(hrRate<10)
      cout<<"Rate = "<<hrRate<<" is less than minimum wage (min wage is 10$)"<<endl;
   if(hours>0 && hrRate>=10)
      cout<<"Employee's Wage is:$ "<<CalculateHourlySalary(hrRate,hours)<<endl;
   cout<<endl;
   return 0;
}//method that takes as input an employee;s hours worked and regular pay rate and outputs the employees wages for the week
double CalculateHourlySalary(int hrRate, int hours)
{
   double salary;
   //she receives her regular rate for the firs t40 hours
   if ( hours <= 40 )
       salary = hours * hrRate;
   //1.5 times her regular rate for each hour between 40 and 50 hours
   else if(hours > 40 && hours<=50)
   salary = 40.0 * hrRate + ( hours - 40 ) * hrRate * 1.5;
   //double her regular rate for each hour over 50
   else if(hours >50)
   salary = 50.0 * hrRate + ( hours - 50 ) * hrRate * 2;
   return salary;
}

C\Program Files (x86)\Dev-Cpp\ConsolePauser.exe Employees wage calculator Enter Emplo yees Hours Worked: 10 Enter Regular Pa

C\Program Files (x86)\Dev-Cpp\Co Employeeswage calculator Enter Emplo ye e s Hours Worked: -3 Enter Regular Pay Rate:$ 12 H

CAProgram Files (x86)\Dev-Cpp\ConsolePauser Employees wage calculator Enter Emplo yees Hours Worked: -3 Enter Regular Pay R

C\Program Files (x86)\Dev-Cpp\Console Employees wage calculator Enter Employees HoursWorked: 30 Enter Regular Pay Rate:$ 20

C\Program Files (x86)\Dev-Cpp\ConsolePauser, Employees wage calculator Enter Emplo yees Hours Worked: 45 Enter Regular Pay

C:\Program Files (x86)\Dev-Cpp\ConsolePause Employees wage calculator Enter Emplo yees Hours Worked: 55 Enter Regular Pay R

Add a comment
Know the answer?
Add Answer to:
C++ program Please only (if) (else) statements No while statements use Write a program that takes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program description: Write the necessary C++ statements (Program) to calculate the employee's weekly pay. Where :...

    Program description: Write the necessary C++ statements (Program) to calculate the employee's weekly pay. Where : Hour = employee's work hours Rate = employee's hourly pay Wages = employee's weekly pay Given that ( Hour= 31.5 and , Rate = $11.45) Write the variable declarations and initialization sections necessary to compute and print the required calculations. The program should ask the user to input the hours and Rate of pay, then calculate the weekly Wages. Hint: Modify program in project...

  • Java: can also use “if else” statements Write a program that can convert an integer between...

    Java: can also use “if else” statements Write a program that can convert an integer between 0 and 15 into hex number (including 0 and 15). The user enters an integer from the console and the program displays the corresponding hex number. If the user enters an integer out of range, the program displays a warning message about the invalid input. Table. Conversion between Decimal and Hexadecimal Decimal Hexadecimal 0 0 1 1 2 2 3 3 4 4 5...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • Write a program to run the following methods in C#. 2) Write a method that takes...

    Write a program to run the following methods in C#. 2) Write a method that takes in a teacher’s last name and exam number via parameters. Ask the teacher (using her name) to tell you the highest score on that exam. Your question should look something like “Ms. Jones, what was the highest grade on test two?” Return the value of the highest grade to the calling method. 3) Write a function called MinOfThree that takes in three numbers and...

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

  • C++ USE WHILE LOOP PLEASE IN CLASS HURRY Write a code in visual studios C++ that...

    C++ USE WHILE LOOP PLEASE IN CLASS HURRY Write a code in visual studios C++ that executes the following: - Ask the user which variable they would like to sweep. You can ask them to choose between options 1-5, listing what those options are, and based on their selection, ask the relevant question using a branching routine. Alternatives are as follows (the user needs to choose one from these options): 1) Cost of cashier per hour (in dollars). Sweep range:...

  • 1.Calculate the Regular Pay and Overtime Pay based on a regular 40-hour workweek in cells F5...

    1.Calculate the Regular Pay and Overtime Pay based on a regular 40-hour workweek in cells F5 and G5 respectively. Pay overtime only for overtime hours. Note that the base work hours and overtime rate is given under the Assumptions section of the Payroll Data worksheet. In cell H5, calculate the Gross Pay based on the regular and overtime pay. 2. Write a formula in cell I5 to calculate the Taxable Pay. Multiply the number of dependents (given in column C)...

  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

  • PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program tha...

    PLEASE WRITE CODE FOR C++ ! Time Validation, Leap Year and Money Growth PartA: Validate Day and Time Write a program that reads a values for hour and minute from the input test file timeData.txt . The data read for valid hour and valid minute entries. Assume you are working with a 24 hour time format. Your program should use functions called validateHour and validateMinutes. Below is a sample of the format to use for your output file  timeValidation.txt :   ...

  • C++ PLEASE UN 15 MINUTES IN CLASS USE WHILE LOOP Write a code in visual studios...

    C++ PLEASE UN 15 MINUTES IN CLASS USE WHILE LOOP Write a code in visual studios C++ that executes the following: - Ask the user which variable they would like to sweep. You can ask them to choose between options 1-5, listing what those options are, and based on their selection, ask the relevant question using a branching routine. Alternatives are as follows (the user needs to choose one from these options): 1) Cost of cashier per hour (in dollars)....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT