r/CPPtogether • u/trooflaw • Feb 11 '20
Assignment 2
Write a program that asks the user to input an employees name, then separately, hours worked. The program should multiply the hours worked by a pay rate of $18.50. The user would like the program to return the name and hours entered, the pay rate, and the total net pay for the employee, on separate lines. Ultimately, the program should output:
Employee name: (nameInput)
Hours worked: (hoursInput)
Pay rate: 18.50
Net pay: (product of hoursInput and pay rate)
3
Upvotes
View all comments
Show parent comment
3
u/Mninek Feb 11 '20
Why not initialize double netPay after you get a value for hoursWorked? After that just output everything as normal. Also any particular reason why you don't just initialize like double payRate = 18.50? I know they are both the same but the way you did seems like it might get confusing if youre just starting out. Not sure if one is better than the other though.