Advertisement
Stelios_Gakis

Savvas_With_Methods

Oct 10th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     private static final Scanner in = new Scanner(System.in);
  6.  
  7.     public static void main(String[] args) {
  8.         Main myApp = new Main();
  9.  
  10.         System.out.println("Please enter the expected time of the flight");
  11.         int expectedTime = in.nextInt();
  12.  
  13.         System.out.println("Please enter the real time of the flight");
  14.         int finalTime = in.nextInt();
  15.  
  16.         int acceptedDelay = myApp.acceptedDelayCalculation(expectedTime);
  17.  
  18.         String result = myApp.delayCalculation(expectedTime, acceptedDelay, finalTime);
  19.  
  20.         System.out.printf("The time delay is : %s", result);
  21.     }
  22.  
  23.     private String delayCalculation (int expectedTime, int acceptedDelay, int finalTime){
  24.         String returnValue;
  25.         if (finalTime + acceptedDelay < expectedTime ) {
  26.             returnValue = "SMALL";
  27.         } else if (finalTime - acceptedDelay > expectedTime) {
  28.             returnValue = "BIG";
  29.         } else {
  30.             returnValue = "GOOD";
  31.         }
  32.         return returnValue;
  33.     }
  34.  
  35.     private int acceptedDelayCalculation(int expectedTime) {
  36.         int returnValue = 0;
  37.         if (expectedTime < 0) {
  38.             System.out.println("Please enter a proper amount");
  39.             acceptedDelayCalculation(expectedTime);
  40.         } else if (expectedTime < 30) {
  41.             returnValue = 1;
  42.         } else if (expectedTime < 60) {
  43.             returnValue = 2;
  44.         } else if (expectedTime < 90) {
  45.             returnValue = 3;
  46.         } else if (expectedTime < 120) {
  47.             returnValue = 4;
  48.         } else if (expectedTime < 180) {
  49.             returnValue = 6;
  50.         } else if (expectedTime < 240) {
  51.             returnValue = 8;
  52.         } else if (expectedTime < 360) {
  53.             returnValue = 13;
  54.         } else  {
  55.             returnValue = 17;
  56.         }
  57.         return returnValue;
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement