Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ex09SkiTrip {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- String room = scanner.nextLine();
- String evaluation = scanner.nextLine();
- int nights = days - 1;
- double totalPrice = 0;
- switch (room) {
- case "president apartment":
- if (days <= 10) {
- totalPrice = nights * 35.00 * 0.9;
- } else if (days <= 15) {
- totalPrice = nights * 35.00 * 0.85;
- } else {
- totalPrice = nights * 35.00 * 0.8;
- }
- break;
- case "apartment":
- if (days <= 10) {
- totalPrice = nights * 25.00 * 0.7;
- } else if (days <= 15) {
- totalPrice = nights * 25.00 * 0.65;
- } else {
- totalPrice = nights * 25.00 * 0.5;
- }
- break;
- default:
- totalPrice = nights * 18.00;
- break;
- }
- if (evaluation.equals("positive")) {
- totalPrice *= 1.25;
- } else {
- totalPrice *= 0.9;
- }
- System.out.printf("%.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement