Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

Write a program that has four functions that do the following A ma

Beoordeling
-
Verkocht
-
Pagina's
2
Cijfer
A
Geüpload op
26-06-2023
Geschreven in
2022/2023

Write a program that has four functions that do the following: A main() function that has a loop that calls the other three functions until a user enters ‘n’ in response to the question, “Do you need more payroll calculations? (y/n) ” An inputData() function to input employee name, hours worked and pay rate A computePay() function to calculate the amount to be paid based on the formula: For the first 40 hours, the rate is the given rate; For hours over 40, the rate is 1.5 times the given rate An displayPay() function to output the name and the amount to be paid. Example: The amount to be paid to John Doe in this pay period is $754.80 Write a statement at the bottom of the program to call the main() function. Solution #include #include using namespace std; void inputData(string &name, float &hours, float &payRate) { cout"Enter name: "; cinname; cout"Enter hours worked: "; cinhours; cout"Enter pay rate: "; cinpayRate; } float computePay(float hours, float payRate) { float pay; if (hours = 40) { pay = hours*payRate; } else { pay = hours*payRate*1.5; } return pay; } void displayPay(string name, float pay) { cout"The amount to be paid to "ch; cout" ";} while (ch != 'n'); return 0; }

Meer zien Lees minder

Voorbeeld van de inhoud

Write a program that has four functions that do the following: A main() function that has a loop
that calls the other three functions until a user enters ‘n’ in response to the question, “Do you
need more payroll calculations? (y/n) ” An inputData() function to input employee name, hours
worked and pay rate A computePay() function to calculate the amount to be paid based on the
formula: For the first 40 hours, the rate is the given rate; For hours over 40, the rate is 1.5 times
the given rate An displayPay() function to output the name and the amount to be paid. Example:
The amount to be paid to John Doe in this pay period is $754.80 Write a statement at the bottom
of the program to call the main() function.


Solution


#include
#include
using namespace std;
void inputData(string &name, float &hours, float &payRate) {
cout<<\"Enter name: \";
cin>>name;
cout<<\"Enter hours worked: \";
cin>>hours;
cout<<\"Enter pay rate: \";
cin>>payRate;
}
float computePay(float hours, float payRate) {
float pay;


if (hours >= 40) {
pay = hours*payRate;
} else {
pay = hours*payRate*1.5;
}
return pay;
}
void displayPay(string name, float pay) {
cout<<\"The amount to be paid to \"<>ch;
cout<<\"\ \ \";

Documentinformatie

Geüpload op
26 juni 2023
Aantal pagina's
2
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden
€6,99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
meejuhaszjasmynspe52866

Maak kennis met de verkoper

Seller avatar
meejuhaszjasmynspe52866 Self
Bekijk profiel
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
2 jaar
Aantal volgers
0
Documenten
338
Laatst verkocht
-

0,0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen