skipter

Firm - Working Project / Math.ceil/floor Java Basics

May 3rd, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package com.company;
  2. import java.util.Scanner;
  3. public class Main {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.         int neededWorkingHours = Integer.parseInt(input.nextLine());
  9.         int daysForTheProject = Integer.parseInt(input.nextLine());
  10.         int overtimeWorkingMan = Integer.parseInt(input.nextLine());
  11.  
  12.         double educationTime = daysForTheProject * 0.10;
  13.         double timeForTheProject = daysForTheProject - educationTime;
  14.         double hoursForWork = timeForTheProject * 8;
  15.         double overtimeWorkingHours = overtimeWorkingMan * (2 *daysForTheProject);
  16.         double totalHours = overtimeWorkingHours + hoursForWork;
  17.  
  18.         double diff = totalHours - neededWorkingHours;
  19.         if (diff >= 0) {
  20.             System.out.printf("Yes!%d hours left.", (int) Math.floor(diff));
  21.         } else if (diff < 0) {
  22.             System.out.printf("Not enough time!%d hours needed.", (int) Math.abs(Math.floor(diff)));
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment