Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SkiTrip_10 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int days = Integer.parseInt(scan.nextLine());
- int nights = days - 1;
- String room = scan.nextLine();
- String review = scan.nextLine();
- int price = 0;
- double discount = 0;
- switch (room) {
- case "room for one person":
- price = 18;
- break;
- case "apartment":
- price = 25;
- break;
- case "president apartment":
- price = 35;
- break;
- }
- if (nights < 10) {
- if (room.equals("apartment")) {
- discount = 0.3;
- } else if (room.equals("president apartment")) {
- discount = 0.1;
- }
- } else if (nights >= 10 && nights <= 15) {
- if (room.equals("apartment")) {
- discount = 0.35;
- } else if (room.equals("president apartment")) {
- discount = 0.15;
- }
- } else if (nights > 15) {
- if (room.equals("apartment")) {
- discount = 0.5;
- } else if (room.equals("president apartment")) {
- discount = 0.2;
- }
- }
- double totalPrice = nights * price;
- double endPrice = totalPrice * (1 - discount);
- if (review.equals("positive")) {
- endPrice *= 1.25;
- } else {
- endPrice *= 0.9;
- }
- System.out.printf("%.2f", endPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment