Advertisement
veronikaaa86

Firm

Oct 12th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.01 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class P02_Firm {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         DecimalFormat df = new DecimalFormat("0.##");
  8.  
  9.         int needHours = Integer.parseInt(scanner.nextLine());
  10.         int haveDays = Integer.parseInt(scanner.nextLine());
  11.         int countWorkersExtra = Integer.parseInt(scanner.nextLine());
  12.  
  13.         double minusTraining = haveDays-(haveDays*0.1);
  14.         double haveHour = minusTraining*8;
  15.         double extraHours = Math.floor(countWorkersExtra*(haveDays*2));
  16.         double allHour = Math.floor(haveHour+extraHours);
  17.  
  18.         double left = 0.0;
  19.         double need = 0.0;
  20.  
  21.         if (needHours<=allHour) {
  22.             left=allHour-needHours;
  23.             System.out.printf("Yes!%s hours left.", df.format(left));
  24.         } else {
  25.             need=needHours-allHour;
  26.             System.out.printf("Not enough time!%s hours needed.", df.format(need));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement