Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SkiTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine())-1;
- String room = scanner.nextLine();
- String assessment = scanner.nextLine();
- double price = 0;
- if (days < 10) {
- switch (room) {
- case "room for one person":
- price = 18.0 * days;
- break;
- case "apartment":
- price = 25.0 * days - (25.0 * days * 0.3);
- break;
- default:
- price = 35.0 * days - (35.0 * days * 0.1);
- break;
- }
- } else if (days <= 15) {
- switch (room) {
- case "room for one person":
- price = 18.0 * days;
- break;
- case "apartment":
- price = 25.0 * days - (25.0 * days * 0.35);
- break;
- default:
- price = 35.0 * days - (35.0 * days * 0.15);
- break;
- }
- } else {
- switch (room) {
- case "room for one person":
- price = 18.0 * days;
- break;
- case "apartment":
- price = 25.0 * days - (25.0 * days * 0.5);
- break;
- default:
- price = 35.0 * days - (35.0 * days * 0.2);
- break;
- }
- }
- if (assessment.equals("positive")) {
- double finalPrice = price * 1.25;
- System.out.printf("%.2f", finalPrice);
- } else {
- double finalPrice = price - (price * 0.1);
- System.out.printf("%.2f", finalPrice);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement