🔒 Closed Help po grade 11 po ako :(

Status
Not open for further replies.

Icchuidian

Leecher
Using an if/else construct, write a program hat will calculate a person's pay based on the number of hours workes.

Take note o the following:
*The pay is Php 35.00 per hour. Any hours worked after 40 hours is ρáíd at the rate of 1.5 times the normal hourly rate.
Calculate and display the normal pay, overtime pay, and the total pay.

Help pls. thank you :)
 
Parang kulang yung tanong
- hindi naka indicate kung ilang hours sya nag worked and kung ilang rin yung overtime nya.
 
Teka, bigay na lang ako ng solution pero hindi ito code.

Normal pay = Work hours x 35

Condition for overtime pay:
If work hours > 40
Overtime pay = (Total work hours - 40) x (35 x 1.5)

Total pay = Normal pay + Overtime pay
 
Ang thought dyan, if person worked for less than or equal sa 40 hours = hours x 35.00.
- If(p <= 40)


And then if else person worked for greater than 40 hours = hours x 45.( kasi 1.5 x 35.00 = 45)
- Else(p>40)
 
Di tlaga magandang introductory ang Java. Kasi medyo mahirap intindihin yung syntax nya. Mostly sa ibang bansa like US tka Japan schools, intro nila is Python. Simple syntax and easy to understand.
 
bigay ka po muna ng code na nasimulan mo then kung tingin mo po may kulang saka po kami magbibigay ng advise. Salamat po :)
 
import java.util.*;
public class Sahod {
public static void main(String[] args) {
System.out.println("Number of Hour(s): ");
Scanner input = new Scanner(System.in);

int Hour = input.nextInt();
int Perhour = 35;
int Normalpay = 0;
double Overtimepay = 0;
int Totalpay = 0;

if (Hour <= 40) {
Normalpay = Hour * Perhour;
Totalpay = Normalpay;
}else {
Normalpay = 40 * Perhour;
Overtimepay = Perhour * ((Hour - 40) * 1.5);
Totalpay = Normalpay + Totalpay;
}

System.out.println("Normal Pay: " + Normalpay);
System.out.println("Overtime Pay: " + Overtimepay);
System.out.println("Total Pay: " + Totalpay);
}
}
 
Status
Not open for further replies.

About this Thread

  • 15
    Replies
  • 1K
    Views
  • 12
    Participants
Last reply from:
Acumen18

Trending Topics

Online now

Members online
1,201
Guests online
893
Total visitors
2,094

Forum statistics

Threads
2,279,277
Posts
28,989,447
Members
1,226,780
Latest member
rhaiikir
Back
Top