Computer Applications
A security agency pays to their staff as per the tariff given below:
| Hours | Rate |
|---|---|
| For first 48 hours in a week | ₹1000 per hour |
| For next 8 hours in a week | ₹1250 per hour |
| For further hours in a week | ₹1500 per hour |
Write a program in Java to calculate the weekly wages of the staff taking number of hours worked in a week as input.
Answer
import java.util.Scanner;
public class KboatSecurityAgency
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter no. of hours: ");
int hr = in.nextInt();
double wage = 0;
if (hr <= 48) {
wage = hr * 1000;
}
else if (hr <= 56) {
wage = (48 * 1000) + ((hr - 48) * 1250);
}
else {
wage = (48 * 1000) + (8 * 1250) + ((hr - 56) * 1500);
}
System.out.println("Weekly Wage = " + wage);
}
}Output
Related Questions
Which of the following is not true with regards to a switch statement?
- checks for an equality between the input and the case labels
- supports floating point constants
- break is used to exit from the switch block
- case labels are unique
The statement that brings the control back to the calling method is:
- break
- System.exit(0)
- continue
- return