skipter

Work Hours - Java Basics Exam 18 March 2017

May 1st, 2017
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FOX {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.     int neededHours = Integer.parseInt(input.nextLine());
  9.     int workersCount = Integer.parseInt(input.nextLine());
  10.     int workingDays = Integer.parseInt(input.nextLine());
  11.  
  12.     int manWorkingHours = (workingDays * workersCount) * 8;
  13.     int diff = Math.abs(neededHours - manWorkingHours);
  14.     int penalties = diff * workingDays;
  15.  
  16.     if (manWorkingHours >= neededHours) {
  17.         System.out.printf("%d hours left", diff);
  18.     }
  19.  
  20.  
  21.  
  22.     if (manWorkingHours < neededHours) {
  23.         System.out.printf("%d overtime%n", diff);
  24.         System.out.printf("Penalties: %d", penalties);
  25.     }
  26.     }
  27.  }
Advertisement
Add Comment
Please, Sign In to add comment