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());
- String room = scanner.nextLine();
- String grade = scanner.nextLine();
- double price = 0;
- int nights = days - 1;
- if ("room for one person".equals(room)) {
- price = nights * 18; // трябва да умножим по броя на нощувките
- } else if ("apartment".equals(room)) {
- if (nights < 10) {
- price = nights * 25 * 0.7; // или: price = nights * 25; price -= price* 0.3;
- }
- if (nights >= 10 && days <= 15) {
- price = nights * 25 * 0.65; // или: price = nights * 25; price -= price* 0.35;
- }
- if (nights > 15) {
- price = nights * 25 * 0.5; // или: price = nights * 25; price -= price* 0.5;
- }
- } else if ("president apartment".equals(room)) { // Тук трябва да затворим горния else if
- if (nights < 10) {
- price = nights * 35 * 0.9; // или: price = nights * 35; price -= price* 0.1;
- }
- if (nights >= 10 && days <= 15) {
- price = nights * 35 * 0.85; // или: price = nights * 35; price -= price* 0.15;
- }
- if (nights > 15) {
- price = nights * 35 * 0.8; // или: price = nights * 35; price -= price* 0.2;
- }
- }
- if ("positive".equals(grade)){
- System.out.printf("%.2f", price * 1.25); // или: System.out.printf("%.2f", price + price* 0.25);
- }else if ("negative".equals(grade)){
- System.out.printf("%.2f", price * 0.9); // или: System.out.printf("%.2f", price - price* 0.1);
- }
- //} Тук свършваше else if ("apartment".equals(room))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement