Advertisement
Spocoman

04. Car To Go

Aug 26th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class CarToGo {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double budget = Double.parseDouble(scanner.nextLine());
  7.         String season = scanner.nextLine();
  8.  
  9.         String car = "Jeep", carClass = "Luxury class";
  10.  
  11.         if (budget > 500) {
  12.             budget *= 0.90;
  13.         } else if (budget > 100) {
  14.             if (season.equals("Summer")) {
  15.                 car = "Cabrio";
  16.                 budget *= 0.45;
  17.             } else {
  18.                 budget *= 0.80;
  19.             }
  20.             carClass = "Compact class";
  21.         } else if (budget > 0) {
  22.             if (season.equals("Summer")) {
  23.                 car = "Cabrio";
  24.                 budget *= 0.35;
  25.             } else {
  26.                 budget *= 0.65;
  27.             }
  28.             carClass = "Economy class";
  29.         }
  30.  
  31.         System.out.printf("%s\n%s - %.2f\n", carClass, car, budget);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement