Advertisement
GabrielHr00

09. Ski Trip

Mar 24th, 2024
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package _03_ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SkiTrip {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int days = Integer.parseInt(scanner.nextLine());
  9.         String roomType = scanner.nextLine();
  10.         String grade = scanner.nextLine();
  11.  
  12.         int nights = days - 1;
  13.         double finalSum = 0.0;
  14.  
  15.         if (roomType.equals("room for one person")) {
  16.             finalSum = 18.0 * nights;
  17.  
  18.         } else if (roomType.equals("apartment")) {
  19.             finalSum = 25.0 * nights;
  20.  
  21.             if (days < 10) {
  22.                 finalSum = finalSum * 0.70;
  23.             } else if (days >= 10 && days <= 15) {
  24.                 finalSum = finalSum * 0.65;
  25.             } else if (days > 15) {
  26.                 finalSum = finalSum * 0.50;
  27.             }
  28.  
  29.         } else if (roomType.equals("president apartment")) {
  30.             finalSum = 35.0 * nights;
  31.  
  32.             if (days < 10) {
  33.                 finalSum = finalSum * 0.90;
  34.             } else if (days >= 10 && days <= 15) {
  35.                 finalSum = finalSum * 0.85;
  36.             } else if (days > 15) {
  37.                 finalSum = finalSum * 0.80;
  38.             }
  39.         }
  40.  
  41.         if (grade.equals("positive")) {
  42.             finalSum = finalSum * 1.25;
  43.         } else {
  44.             finalSum = finalSum * 0.90;
  45.         }
  46.  
  47.         System.out.printf("%.2f", finalSum);
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement