Question

Write a C++ console application that uses functions to calculate an employee’s salary.


Write a C++ console application that uses functions to calculate an employee’s salary.

PART 1: Create a void function to print a menu asking the user to choose from the following options:

1 - Annual salary

2 - Monthly salary

3 - Daily rate of pay

4 – Exit


The void function only prints the menu. Format your cout statement to include the menu as displayed above.

If the chosen option is 1- Annual Salary, ask the user for the number of hours they work perweek and their hourly wage:

Annual Salary = hourly wage x hours worked per week x 52

If the chosen option is 2- Monthly Salary, ask the user for the number of hours they work perweek and their hourly wage:

Monthly Salary = Annual Salary / 12

If the chosen option is 3- Daily Rate of Pay, ask the user for the number of hours they work perday and their hourly wage:

Daily Rate of Pay = hours worked in a day x hourly wage

PART 2: Create different double functions to calculate each of these rates.

Continue to prompt the user for a value until an invalid option is entered. The sentinel value in this application is 4 (Exit). An invalid option would be anything other than 1,2,3, and 4. Output the information back to the user in columns with one column including labels and the other including a value. Be sure to include the units for the values printed to the screen. Format any real numbers to two decimal places.

[your program code here]*

If possible, format your code like this:

Font “Courier New”

       Font size “9”

       Bold

[your program output here]**

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

#include
using namespace std;

void menu() //menu function
{
//creating menu for the user
cout<<"1 - Annual salary"< cout<<"2 - Monthly salary"< cout<<"3 - Daily rate of pay"< cout<<"4 – Exit"< }
double annual() //annual salary calculation
{
double sal,hr,wg; //variable declaration
//accepting values from user
cout<<"Number of hours worked per week"< cin>>hr;
cout<<"Hourly wage"< cin>>wg;
sal= (wg * hr * 52);
return sal; //returning the result
}
double month() //monthly salary calculation
{
double sal,hr,wg; //variable declaration
//accepting values from the user
cout<<"Number of hours worked per week"< cin>>hr;
cout<<"Hourly wage"< cin>>wg;
sal= (wg * hr * 52)/12;
return sal; //returning the result
}
double day() //per day salary calculation
{
double sal,hr,wg; //variable declaration
//accepting values from the user
cout<<"Number of hours worked per day"< cin>>hr;
cout<<"Hourly wage"< cin>>wg;
sal= (wg * hr);
return sal; //returning the result
}
int main()
{
int ch; //variable declaration
double res=0.0;
do{
menu(); //calling the menu function
cout<<"Enter your choice "< cin>>ch;
switch(ch)
{
case 1:
res=annual(); //calling the annual function
cout<<"The Annual Wage : "< break;
case 2:
res=month(); //calling the month function
cout<<"The Monthly Wage : "< break;
case 3:
res=day(); //calling the day function
cout<<"The Daily Wage : "< break;
case 4:
exit(0); //system exit
default:
cout<<"Invalid Choice"< break;
}
}while(ch!=4);
return 0;
}

OUTPUT

Add a comment
Know the answer?
Add Answer to:
Write a C++ console application that uses functions to calculate an employee’s salary.
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
  • Develop a WPF application that has a button to calculate an employee’s weekly pay, given the...

    Develop a WPF application that has a button to calculate an employee’s weekly pay, given the number of hours worked. An employee should have a first name, last name, age, and hourly consulting rate. You should be able to create an employee object and provide the hours worked to calculate the weekly pay. The application assumes a standard workweek of 40 hours. Any hours worked over 40 hours in a week are considered overtime and earn time and a half....

  • 1. Write a C++ program that will ask the user for their full name and calculate...

    1. Write a C++ program that will ask the user for their full name and calculate the user's weekly salary based on their hourly wage and the number of hours they worked, assuming no overtime at this point. Sample program run: Please enter first name: Elmer Please enter middle initial (Enter space if none): J Please enter last name: Fudd Enter hours worked: 37.5 Enter hourly rate: 10.35 Your name is: Elmer J. Fudd Your weekly salary is: $388.12 2....

  • Code should be written in C++ 2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console a...

    Code should be written in C++ 2. [11] You have been hired by Shapes Calculator Menu Maker to create a C++ console application that prompts the user with a menu and various options. Starting from Lab03, prompt the user for a char value that corresponds to one of the following menu options: a. Sphere=4*pi"radius3 (hint: use a constant value for pi=3.1415) b. Right Circular Cylinder- piradius*height c. Rectangular Parallelepiped length *width height d. Cone-*pi*radius2 height 3 x. Exit menu. Implement...

  • use at least two functions in your program. . Write a program that calculates weekly payment....

    use at least two functions in your program. . Write a program that calculates weekly payment. The program will ask the user full name, ID number (make one up), and hours worked. An hourly worker’s gross pay is basically his/her work hours that week multiplied by his/her regular hourly pay rate. However, after the first 40 work hours of the week, each additional work hour is paid at an overtime rate that is 1.5 times of the regular hourly rate....

  • Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate...

    Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate and print the monthly pay of an employee. The application starts by printing a short description of what it does. Then, it asks for the employee name. Next, the application prompts for employee type (“H” for hourly and “S” for salaried.) If the user enters S, the gross pay is set to $4000. However, if the user enters H for an hourly employee, the...

  • Debug and fix the Java console application that uses 2 dimensional arrays but the application does...

    Debug and fix the Java console application that uses 2 dimensional arrays but the application does not compile nor execute. Student enters only integers to select courses for registration from a menu. No data type validation of the user menu selection is checked or required. The program terminates only when the student closes it. No registration of other courses not displayed by the program . No registration more than once for the same course. No registration for more than 9...

  • Program 3. Decisions Due: Friday, February 7 by 11:59 PM Overview For this program, design a...

    Program 3. Decisions Due: Friday, February 7 by 11:59 PM Overview For this program, design a wage calculator for a single user. The program will use the user's number of hours worked and their hourly wage to calculate: Gross Pay Deduction Net Pay The Gross Pay is the amount that the user is paid before any deduction is applied. The pay amount is based upon the number of hours worked. If 40 hours or less were worked, the gross pay...

  • If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly...

    If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...

  • in C++ Write a program which uses the following arrays: empID: An array of 7 integers...

    in C++ Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program...

  • Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve...

    Develop a flowchart and then write a menu-driven C++ program that uses several FUNCTIONS to solve the following program. -Use Microsoft Visual C++ .NET 2010 Professional compiler using default compiler settings. -Use Microsoft Visio 2013 for developing your flowchart. -Adherence to the ANSI C++  required -Do not use <stdio.h> and <conio.h>. -Do not use any #define in your program. -No goto statements allowed. Upon execution of the program, the program displays a menu as shown below and the user is prompted to make a selection from the menu....

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