Advertisement
veronikaaa86

03. Mobile operator

Jun 24th, 2023
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.74 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03MobileOperator {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String yearContract = scanner.nextLine();
  10.         String typeContract = scanner.nextLine();
  11.         String mobileNet = scanner.nextLine();
  12.         int months = Integer.parseInt(scanner.nextLine());
  13.        
  14.         double amount = 0;
  15.         if (yearContract.equals("one")) {
  16.             if (typeContract.equals("Small")) {
  17.                 amount = 9.98;
  18.             } else if (typeContract.equals("Middle")) {
  19.                 amount = 18.99;
  20.             } else if (typeContract.equals("Large")) {
  21.                 amount = 25.98;
  22.             } else if (typeContract.equals("ExtraLarge")) {
  23.                 amount = 35.99;
  24.             }
  25.         } else if (yearContract.equals("two")) {
  26.             if (typeContract.equals("Small")) {
  27.                 amount = 8.58;
  28.             } else if (typeContract.equals("Middle")) {
  29.                 amount = 17.09;
  30.             } else if (typeContract.equals("Large")) {
  31.                 amount = 23.59;
  32.             } else if (typeContract.equals("ExtraLarge")) {
  33.                 amount = 31.79;
  34.             }
  35.         }
  36.  
  37.         if (mobileNet.equals("yes")) {
  38.             if (amount <= 10) {
  39.                 amount = amount + 5.50;
  40.             } else if (amount <= 30) {
  41.                 amount = amount + 4.35;
  42.             } else {
  43.                 amount = amount + 3.85;
  44.             }
  45.         }
  46.  
  47.         double totalSum = amount * months;
  48.  
  49.         if (yearContract.equals("two")) {
  50.             totalSum = totalSum - (totalSum * 0.0375);
  51.         }
  52.  
  53.         System.out.printf("%.2f lv.%n", totalSum);
  54.     }
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement