Advertisement
tenachev

MobilOperator

Apr 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.53 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MobileOperator {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String termOfTheContract = scanner.nextLine().toLowerCase(); //srok na dogovora
  8.         String typeOfTheContranct = scanner.nextLine(); // vid na dogovora
  9.         String bonusInternet = scanner.nextLine().toLowerCase();
  10.         int numberMonth = Integer.parseInt(scanner.nextLine());
  11.  
  12.         // Za 1 godina
  13.         double smallOne = 9.98;
  14.         double middleOne = 18.99;
  15.         double largeOne = 25.98;
  16.         double extraLargeOne = 35.99;
  17.         double mobilInternet = 5.50;
  18.         double mobilInternet30 = 4.35;
  19.         double mobilInternetOver30 = 3.85;
  20.  
  21.         double withMobilNet = 0;
  22.         double endPrice = 0;
  23.  
  24.         if (termOfTheContract.equals("one")) {
  25.             if (typeOfTheContranct.equals("Small") && bonusInternet.equals("yes")) {
  26.  
  27.                 withMobilNet = smallOne + mobilInternet;
  28.                 endPrice = withMobilNet * numberMonth;
  29.                 System.out.printf("%.2f lv.", endPrice);
  30.  
  31.             } else if (typeOfTheContranct.equals("Small") && bonusInternet.equals("no")) {
  32.                 endPrice = smallOne * numberMonth;
  33.                 System.out.printf("%.2f lv.", endPrice);
  34.             }
  35.             if (typeOfTheContranct.equals("Middle") && bonusInternet.equals("yes")) {
  36.                 withMobilNet = middleOne + mobilInternet30;
  37.                 endPrice = withMobilNet * numberMonth;
  38.                 System.out.printf("%.2f lv.", endPrice);
  39.  
  40.             } else if (typeOfTheContranct.equals("Middle") && bonusInternet.equals("no")) {
  41.                 endPrice = middleOne * numberMonth;
  42.                 System.out.printf("%.2f lv.", endPrice);
  43.             }
  44.             if (typeOfTheContranct.equals("Large") && bonusInternet.equals("yes")) {
  45.                 withMobilNet = largeOne + mobilInternet30;
  46.                 endPrice = withMobilNet * numberMonth;
  47.                 System.out.printf("%.2f lv.", endPrice);
  48.  
  49.             } else if (typeOfTheContranct.equals("Large") && bonusInternet.equals("no")) {
  50.                 endPrice = largeOne * numberMonth;
  51.                 System.out.printf("%.2f lv.", endPrice);
  52.             }
  53.             if (typeOfTheContranct.equals("ExtraLarge") && bonusInternet.equals("yes")) {
  54.                 withMobilNet = extraLargeOne + mobilInternetOver30;
  55.                 endPrice = withMobilNet * numberMonth;
  56.                 System.out.printf("%.2f lv.", endPrice);
  57.  
  58.             } else if (typeOfTheContranct.equals("ExtraLarge") && bonusInternet.equals("no")) {
  59.                 endPrice = extraLargeOne * numberMonth;
  60.                 System.out.printf("%.2f lv.", endPrice);
  61.             }
  62.         }
  63.             // Za 2 godini
  64.         double smallTwo = 8.58;
  65.         double middleTwo = 17.09;
  66.         double largeTwo = 23.59;
  67.         double extraLargeTwo = 31.79;
  68.  
  69.         double off = 0;
  70.         double percent = 0.0375;
  71.         double sum = 0;
  72.  
  73.         double withMobilNetTwo = 0;
  74.  
  75.         if (termOfTheContract.equals("two")) {
  76.             if (typeOfTheContranct.equals("Small") && bonusInternet.equals("yes")) {
  77.  
  78.                 withMobilNetTwo = smallTwo + mobilInternet;
  79.                 sum = withMobilNetTwo * numberMonth;
  80.                 off = sum * percent;
  81.                 sum = sum - off;
  82.                 System.out.printf("%.2f lv.", sum);
  83.  
  84.             } else if (typeOfTheContranct.equals("Small") && bonusInternet.equals("no")) {
  85.  
  86.                 sum = numberMonth * smallTwo;
  87.                 off = sum * percent;
  88.                 sum = sum - off;
  89.                 System.out.printf("%.2f lv.", sum);
  90.             }
  91.             if (typeOfTheContranct.equals("Middle") && bonusInternet.equals("yes")) {
  92.  
  93.                 withMobilNetTwo = middleTwo + mobilInternet30;
  94.                 sum = withMobilNetTwo * numberMonth;
  95.                 off = sum * percent;
  96.                 sum = sum - off;
  97.                 System.out.printf("%.2f lv.", sum);
  98.  
  99.             } else if (typeOfTheContranct.equals("Middle") && bonusInternet.equals("no")) {
  100.  
  101.                 sum = numberMonth * middleTwo;
  102.                 off = sum * percent;
  103.                 sum = sum - off;
  104.                 System.out.printf("%.2f lv.", sum);
  105.             }
  106.             if (typeOfTheContranct.equals("Large") && bonusInternet.equals("yes")) {
  107.  
  108.                 withMobilNetTwo = largeTwo + mobilInternet30;
  109.                 sum = withMobilNetTwo * numberMonth;
  110.                 off = sum * percent;
  111.                 sum = sum - off;
  112.                 System.out.printf("%.2f lv.", sum);
  113.  
  114.             } else if (typeOfTheContranct.equals("Large") && bonusInternet.equals("no")) {
  115.  
  116.                 sum = numberMonth * largeTwo;
  117.                 off = sum * percent;
  118.                 sum = sum - off;
  119.                 System.out.printf("%.2f lv.", sum);
  120.             }
  121.             if (typeOfTheContranct.equals("ExtraLarge") && bonusInternet.equals("yes")) {
  122.  
  123.                 withMobilNetTwo = extraLargeTwo + mobilInternetOver30;
  124.                 sum = withMobilNetTwo * numberMonth;
  125.                 off = sum * percent;
  126.                 sum = sum - off;
  127.                 System.out.printf("%.2f lv.", sum);
  128.  
  129.             } else if (typeOfTheContranct.equals("ExtraLarge") && bonusInternet.equals("no")) {
  130.  
  131.                 sum = numberMonth * extraLargeTwo;
  132.                 off = sum * percent;
  133.                 sum = sum - off;
  134.                 System.out.printf("%.2f lv.", sum);
  135.             }
  136.         }
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement