Ligh7_of_H3av3n

03.ExcursionCalculator

Oct 15th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package PodgotovkaZaIzpit;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ExcursionCalculator {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         // Set initial variables
  10.         int tourists = Integer.parseInt(scanner.nextLine());
  11.         String season = scanner.nextLine();
  12.         double pricePerTourist = 0;
  13.  
  14.         // Calculate pricePerTourist depending on season and tourist number
  15.         if (season.equals("spring")) {
  16.             if (tourists > 5) {
  17.                 pricePerTourist = 48;
  18.             } else
  19.             {
  20.                 pricePerTourist = 50;
  21.             }
  22.         } else if (season.equals("summer")) {
  23.             if (tourists > 5)
  24.             {
  25.                 pricePerTourist = 45;
  26.             } else
  27.             {
  28.                 pricePerTourist = 48.50;
  29.             }
  30.         } else if (season.equals("autumn")) {
  31.             if (tourists > 5)
  32.             {
  33.                 pricePerTourist = 49.50;
  34.             } else
  35.             {
  36.                 pricePerTourist = 60;
  37.             }
  38.         } else if (season.equals("winter")) {
  39.             if (tourists > 5)
  40.             {
  41.                 pricePerTourist = 85;
  42.             } else
  43.             {
  44.                 pricePerTourist = 86;
  45.             }
  46.         }
  47.  
  48.         double finalPrice = pricePerTourist * tourists;
  49.        
  50.         if (season.equals("summer")) {
  51.             finalPrice = finalPrice *.85;
  52.         } else if (season.equals("winter")) {
  53.             finalPrice =finalPrice * 1.08;
  54.         }
  55.        
  56.         System.out.printf("%.2f leva.", finalPrice);
  57.      }
  58.     }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment