Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.StringReader;
- import java.text.SimpleDateFormat;
- import java.util.Scanner;
- public class Discount {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String season = scanner.nextLine();
- String classCar = "";
- String typeCar = "";
- double prize = 0;
- switch (season) {
- case "Summer":
- typeCar = "Cabrio";
- if (budget <= 100) {
- classCar = "Economy class";
- budget *= 0.35;
- } else if (budget > 500) {
- classCar = "Luxury class";
- budget *= 0.90;
- } else {
- classCar = "Compact class";
- budget *= 0.45;
- }
- break;
- case "Winter":
- typeCar = "Jeep";
- if (budget <= 100) {
- classCar = "Economy class";
- budget *= 0.65;
- } else if (budget > 500) {
- classCar = "Luxury class";
- budget *= 0.90;
- } else {
- classCar = "Compact class";
- budget *= 0.80;
- }
- break;
- }
- if (classCar.equals("Luxury class")){
- typeCar = "Jeep";
- }
- System.out.println(classCar);
- System.out.printf("%s - %.2f", typeCar, budget);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment