Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SalaryCalculator {
- public void Salary() {
- Scanner input = new Scanner(System.in);
- int hours = 40;
- int hoursExtra = 0;
- int totalHours;
- double salary = 200; // salary per hour = 5
- double salaryPerHourExtra = 2.5;
- double totalSalary;
- int employees = 0;
- while (employees < 3){
- System.out.println("Enter hours: ");
- totalHours = input.nextInt();
- if(totalHours < hours)
- System.out.println("Fired !!");
- if(totalHours > hours)
- {
- hoursExtra = totalHours - hours;
- totalSalary = salary + (hoursExtra * salaryPerHourExtra);
- System.out.println("Hours worked: " + totalHours);
- System.out.println("Salary: " + totalSalary);
- }
- if(totalHours == hours)
- {
- System.out.println("Hours worked: " + hours);
- System.out.println("Salary: " + salary);
- }
- employees++;
- }
- }
- }
- public class SalaryCalculatorTest {
- public static void main(String[] args) {
- SalaryCalculator salary1 = new SalaryCalculator();
- salary1.Salary();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement