Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- private static final Scanner in = new Scanner(System.in);
- public static void main(String[] args) {
- Main myApp = new Main();
- System.out.println("Please enter the expected time of the flight");
- int expectedTime = in.nextInt();
- System.out.println("Please enter the real time of the flight");
- int finalTime = in.nextInt();
- int acceptedDelay = myApp.acceptedDelayCalculation(expectedTime);
- String result = myApp.delayCalculation(expectedTime, acceptedDelay, finalTime);
- System.out.printf("The time delay is : %s", result);
- }
- private String delayCalculation (int expectedTime, int acceptedDelay, int finalTime){
- String returnValue;
- if (finalTime + acceptedDelay < expectedTime ) {
- returnValue = "SMALL";
- } else if (finalTime - acceptedDelay > expectedTime) {
- returnValue = "BIG";
- } else {
- returnValue = "GOOD";
- }
- return returnValue;
- }
- private int acceptedDelayCalculation(int expectedTime) {
- int returnValue = 0;
- if (expectedTime < 0) {
- System.out.println("Please enter a proper amount");
- acceptedDelayCalculation(expectedTime);
- } else if (expectedTime < 30) {
- returnValue = 1;
- } else if (expectedTime < 60) {
- returnValue = 2;
- } else if (expectedTime < 90) {
- returnValue = 3;
- } else if (expectedTime < 120) {
- returnValue = 4;
- } else if (expectedTime < 180) {
- returnValue = 6;
- } else if (expectedTime < 240) {
- returnValue = 8;
- } else if (expectedTime < 360) {
- returnValue = 13;
- } else {
- returnValue = 17;
- }
- return returnValue;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement