Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ * Exercises: 1 . Complete the program below. Sample Run: This program takes two numbers ( pay rate & hours ) and multiplies them

/* Exercises:
1. Complete the program below.
Sample Run:
This program takes two numbers (pay rate & hours) and
multiplies them to get gross pay. It then takes out 15%
for taxes
Please input the pay per hour: 25
Please input the number of hours worked: 10
The gross pay is: $250.00
The net pay is: $212.50
*/
// This calculates a paycheck
#include // Required for cin and cout
#include // Required for setprecision
using namespace std; // Required for not having to use std::
// Function prototypes
void printDescription(); // void function with no parameters
void calculatePaycheck(float, int, float&, float&); // void function with parameters
// The main function
int main(){
float payRate;
int hours;
float grossPay, netPay;
cout << setprecision(2)<< fixed; // Set the precision of the output
printDescription(); // Call the description function
cout << "Please input the pay per hour: ";
cin >> payRate;
cout << "Please input the number of hours worked: ";
cin >> hours;
// Call the calculatePaycheck function
// TODO: Pass the payRate, hours, grossPay, and netPay
cout << "The gross pay is: $"<< grossPay << endl;
cout << "The net pay is: $"<< netPay << endl;
return 0;
}
// The function to print the description
void printDescription(){
cout << "This program takes two numbers (pay rate & hours) and
";
cout << "multiplies them to get gross pay. It then takes out 15%
";
cout << "for taxes
";
}
// The function to calculate the paycheck
void calculatePaycheck(float rate, int time, float& gross, float& net){
gross = rate * time;
net = gross *0.85; //15% tax
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial Databases 2nd Symposium Ssd 91 Zurich Switzerland August 1991 Proceedings Lncs 525

Authors: Oliver Gunther ,Hans-Jorg Schek

1st Edition

3540544143, 978-3540544142

Students also viewed these Databases questions