Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         String year = scanner.nextLine();
  11.         String type = scanner.nextLine();
  12.         String dessert = scanner.nextLine();
  13.         int months = Integer.parseInt(scanner.nextLine());
  14.         double price = 0.0;
  15.         double totalPrice = 0.0;
  16.  
  17.         switch (year) {
  18.             case "one":
  19.                 if (type.equals("Small" )) {
  20.                     price = 9.98;
  21.                 } else if (type.equals("Middle" )) {
  22.                     price = 18.99;
  23.                 } else if (type.equals("Large" )) {
  24.                     price = 25.98;
  25.                 } else if (type.equals("ExtraLarge" )) {
  26.                     price = 35.99;
  27.                 }
  28.                 break;
  29.             case "two":
  30.                 if (type.equals("Small" )) {
  31.                     price = 8.58;
  32.                 } else if (type.equals("Middle" )) {
  33.                     price = 17.09;
  34.                 } else if (type.equals("Large" )) {
  35.                     price = 23.59;
  36.                 } else if (type.equals("ExtraLarge" )) {
  37.                     price = 31.79;
  38.                 }
  39.                 break;
  40.         }
  41.  
  42.         double dessertPrice = 0.0;
  43.  
  44.         if (dessert.equals("yes" )) {
  45.             if (price <= 10) {
  46.                 dessertPrice = 5.5;
  47.             } else if (price <= 30) {
  48.                 dessertPrice = 4.35;
  49.             } else if (price > 30) {
  50.                 dessertPrice = 3.85;
  51.             }
  52.  
  53.         }
  54.  
  55.  
  56.         totalPrice = (price + dessertPrice) * months;
  57.  
  58.         if (year.equals("two" )) {
  59.             totalPrice = totalPrice * 0.375;
  60.  
  61.         }
  62.  
  63.  
  64.         System.out.printf("%.2f lv.", totalPrice );
  65.     }
  66.  
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement