Advertisement
vp0415

lec3.4

Oct 21st, 2014
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SalaryCalculator {
  4.     public void Salary() {
  5.         Scanner input = new Scanner(System.in);
  6.         int hours = 40;
  7.         int hoursExtra = 0;
  8.         int totalHours;
  9.         double salary = 200; // salary per hour = 5
  10.         double salaryPerHourExtra = 2.5;
  11.         double totalSalary;
  12.         int employees = 0;
  13.        
  14.         while (employees < 3){
  15.             System.out.println("Enter hours: ");
  16.             totalHours = input.nextInt();
  17.             if(totalHours < hours)
  18.                 System.out.println("Fired !!");
  19.             if(totalHours > hours)
  20.             {
  21.                 hoursExtra = totalHours - hours;
  22.                 totalSalary = salary + (hoursExtra * salaryPerHourExtra);
  23.                 System.out.println("Hours worked: " + totalHours);
  24.                 System.out.println("Salary: " + totalSalary);
  25.             }
  26.             if(totalHours == hours)
  27.             {
  28.                 System.out.println("Hours worked: " + hours);
  29.                 System.out.println("Salary: " + salary);
  30.             }
  31.             employees++;
  32.            
  33.         }
  34.     }
  35.  
  36. }
  37.  
  38. public class SalaryCalculatorTest {
  39.  
  40.     public static void main(String[] args) {
  41.         SalaryCalculator salary1 = new SalaryCalculator();
  42.         salary1.Salary();
  43.  
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement