Ask your own question, for FREE!
Computer Science 5 Online
OpenStudy (hari5719):

A security man is paid at the hourly rate( R ) for the first 40 hours of work in a week. There after he his paid at 1.25 times the hourly rate (R) for the next 16 hours and 1.5 times the hourly rate ( R) for further hours of work in the week. Taking the number of hours (H) and rate per hour( R) as input, the weekly wage (W) us to be calculated. Write a program to calculate weekly wages and display it. Write an algorithm/Java program to calculate and print the rate(R), hours(H) and wages(W).

OpenStudy (hari5719):

@Nnesha @Zale101 @nincompoop @Whitemonsterbunny17

OpenStudy (hari5719):

@AlexandervonHumboldt2 @Agl202

OpenStudy (hari5719):

@ganeshie8

OpenStudy (kva1992):

That's fairly simple all you would have to do is check if the hours are more than 40 of it is then check if it is more than 16 hours and calculate it like that so for example let's say I worked for 58 hours in that week. So 40 hours would be accounted for at normal pay then I worked 18 hours more so for the next 16 I get paid 1.25 more than what I get paid hourly and since there is still 2 hours left you must multiply 1.50 by the hourly pay and add the sum of all of that and that should give you a total. For the record im trying to help without giving you the syntax. If you have any sort of code post it here and I'll gladly take a look at it and point out mistakes or what you should add if there is anything I do notice. If you want me to clarify anything please do ask.

OpenStudy (hari5719):

class Wages{ public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Please enter hourly rate: "); R = input.nextDouble(); System.out.println("Please enter number of hours worked: "); H= input.nextInt(); if ( 0 < = H && H<= 40) { W = R*H; } else if ( 40< H && H <= 56 { W = 1.25*R * H } else if (H > 56) { W = 1.5*R*H; System.out.println("Total Wages are " + W); } } @kva1992

OpenStudy (hari5719):

???

OpenStudy (kva1992):

Your if statement is wrong. It should be. if ( H>=0 && H<= 40) { W = R*H; } else if ( H >=40 && H <= 56 { W=40*R; W=W+((1.25*R)(H-40)); } else if (H > 56) { W = 40*R; W = W + ((1.25*R)(16)); W = W + ((1.50*R)(H-56));

OpenStudy (kva1992):

That should fix your issue let me know of you want me to explain.

OpenStudy (kva1992):

System.out.println("Total Wages are " + W); Add that after your if statement.

OpenStudy (hari5719):

like how can u show me plsss

OpenStudy (kva1992):

What am I showing you exactly?

OpenStudy (hari5719):

is this right ???? public class Wages{ public static void main(String[] args) { double a,b,c, R, W=0; int H; Scanner input = new Scanner(System.in); System.out.println("Please enter hourly rate: "); R = input.nextDouble(); System.out.println("Please enter number of hours worked: "); H = input.nextInt(); if (H >= 0 && H <= 40) { W = R * H; } else if (H > 40 && H <= 56) { W = R*40 + 1.25 * R * (H-40); } else if (H > 56) { W = R*40 + 1.25 * R * 16 + 1.5 * R * (H-56); } System.out.println("Total Wages are " + W); }

OpenStudy (hari5719):

@kva1992

OpenStudy (hari5719):

CAN u show me the code in algorithm plsss @kva1992

OpenStudy (kva1992):

I would personally separate the calculation just so the program doesn't Compute from left to right and does it properly you could use the ABC variables at the top of the page.

OpenStudy (kva1992):

But essentially you got it

OpenStudy (hari5719):

ya can u show me in pseudocode form

OpenStudy (kva1992):

I can't exactly give you pseudocode right now I'm on my phone won't have a PC for another week or so

OpenStudy (kva1992):

Just type exactly what your program is doing

OpenStudy (kva1992):

Input both user driven and application driven and outputs and calculation the things that happen in the back end in order

OpenStudy (kva1992):

And that will be your pseudocode

OpenStudy (kva1992):

Hopefully that answered all your questions

OpenStudy (hari5719):

thx anyways

OpenStudy (kva1992):

No problem

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
laylasnii13: Who wanna write or make a song with me???
3 hours ago 0 Replies 0 Medals
kaelynw: art igg
2 hours ago 9 Replies 1 Medal
XShawtyX: Art
20 hours ago 6 Replies 0 Medals
Nina001: teach me how to draw or just tell me the basics
23 hours ago 2 Replies 1 Medal
XShawtyX: We doing another drawing gimme ideas to add to this
1 day ago 9 Replies 1 Medal
RAVEN69: What is x 3+y 3+z 3=k
1 day ago 20 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!