I need help with this problem!
I can't get all three to display.
Write a program that prompts a user to enter their hourly pay and rate. Understanding that "time and a half" applies to hours in excess of forty, calculate and print the user's regular pay, overtime pay, and total pay for the week.
Shianne_1
0
Newbie Poster
Recommended Answers
Jump to PostPlease add code for us to look at.
Jump to PostFor hours less than 40 I see 2 print lines that will execute. Lines 5 and 14.
For hours 40 and over, only line 16 and 17 will print.Your code does exactly what you told it to do.
Jump to PostPlug in a few test numbers. What happens if only 35 hours are worked? In that cast the overtime is -5 hours and you get a negative OT pay. Write your program in pseudo-code. Write out the steps you would do if you were doing the accounting by hand. Try …
All 10 Replies
rproffitt
2,565
"Nothing to see here."
Moderator
Shianne_1
0
Newbie Poster
Fifth Horseman
commented:
The regular pay is never displayed when you have overtime pay because of the if/else block you've used. To fix, just remove the if/else statements
+0
rproffitt
2,565
"Nothing to see here."
Moderator
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Shianne_1
0
Newbie Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Shianne_1
commented:
I understand that. I can't get the code to behave correctly that's what I need help with.
+0
Shianne_1
0
Newbie Poster
Fifth Horseman
commented:
Rprofitt is correct, the code does what you told it to. You seem to misunderstand what the if/else statements do.
+0
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
toneewa
81
Junior Poster in Training
Reverend Jim
commented:
You are not helping by writing the code for them.
-3
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
rproffitt
commented:
They learn when the teacher does a web search. Also, I didn't write it and gave attribution. It's a wonder why folk want code that is on the web.
+16
Shianne_1
commented:
I learned what I needed. I am I visual learner. I need to see the code so I could evaluate it and understand the difference between mine and this.
+0
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.