Advertisement
veronikaaa86

Mobile Operator With If

Oct 2nd, 2017
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.33 KB | None | 0 0
  1. package Exam17September2017;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class MobileOperator_If {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String year = scanner.nextLine();
  10.         String tariffType = scanner.nextLine();
  11.         String internet = scanner.nextLine();
  12.         int months = Integer.parseInt(scanner.nextLine());
  13.  
  14.         double value = 0.0;
  15.         double sum = 0.0;
  16.         double allSum = 0.0;
  17.         double allSumDisc = 0.0;
  18.  
  19.         if (tariffType.equals("Small")) {
  20.             if ("one".equalsIgnoreCase(year)) {
  21.                 value = 9.98;
  22.                 sum = value * months;
  23.             } else {
  24.                 value = 8.58;
  25.                 sum = value * months;
  26.             }
  27.  
  28.         } else if (tariffType.equals("Middle")) {
  29.             if ("one".equalsIgnoreCase(year)) {
  30.                 value = 18.99;
  31.                 sum = value * months;
  32.             } else {
  33.                 value = 17.09;
  34.                 sum = value * months;
  35.             }
  36.  
  37.         } else if (tariffType.equals("Large")) {
  38.             if ("one".equalsIgnoreCase(year)) {
  39.                 value = 25.98;
  40.                 sum = value * months;
  41.             } else {
  42.                 value = 23.59;
  43.                 sum = value * months;
  44.             }
  45.  
  46.         } else if (tariffType.equals("ExtraLarge")) {
  47.             if ("one".equalsIgnoreCase(year)) {
  48.                 value = 35.99;
  49.                 sum = value * months;
  50.             } else {
  51.                 value = 31.79;
  52.                 sum = value * months;
  53.             }
  54.  
  55.         } else {
  56.             System.out.println();
  57.         }
  58.         switch (internet) {
  59.             case "yes":
  60.                 if (value <= 10) {
  61.                     allSum = (value + 5.50)*months;
  62.                 } else if (value <= 30) {
  63.                     allSum = (value + 4.35)*months;
  64.                 } else {
  65.                     allSum = (value + 3.85)*months;
  66.                 }
  67.                 break;
  68.             default:
  69.                 allSum = sum;
  70.                 break;
  71.         }
  72.  
  73.         if ("two".equalsIgnoreCase(year)) {
  74.             allSumDisc=allSum-(allSum*0.0375);
  75.             System.out.printf("%.2f lv.", allSumDisc);
  76.         } else {
  77.             System.out.printf("%.2f lv.", allSum);
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement