Draw a flowchart or write pseudocode to represent the logic of a program that al
ID: 672721 • Letter: D
Question
Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter three values. Th e values represent hourly pay rate, the number of hours worked this pay period, and percentage of gross salary that is withheld. Th e program multiplies the hourly pay rate by the number of hours worked, giving the gross pay. Th en, it multiplies the gross pay by the withholding percentage, giving the withholding amount. Finally, it subtracts the withholding amount from the gross pay, giving the net pay after taxes. Th e program outputs the net pay.
Explanation / Answer
I am going to write pseudocode(logic) for this program:
--------------------------------------------------------------
main(){
//declaring variables
double hourlyPayRate,numberOfHoursWorked,percentageWithheld;
//reading values from user
cin>>hourlyPayRate;
cin>>numberOfHoursWorked;
cin>>percentageWithheld;
//now calcualting gross pay
double grossPay = hourlyPayRate * numberOfHoursWorked;
double withHoldAmt = percentageWithheld * grossPay;
//finally for netpay ...
double netPay = grossPay - withHoldAmt;
//outputting netPay
cout<<netPay;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.