Hotel Room - Упражнения: Вложени условни конструкции
Zdraveite,
Nqkoi moje li da mi kaje zashto Judge mi dava 90/100 ????????????
package ConditionalStatementsAdvancedExercise; import java.util.Scanner; public class HotelRoom { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String month = scanner.nextLine(); int nights = Integer.parseInt(scanner.nextLine()); double apartmentPrice = 0.0; double studioPrice = 0.0; switch (month) { case "May": case "October": if (nights < 7) { studioPrice = nights * 50; apartmentPrice = nights * 65; } else if (nights > 7 && nights <= 14) { studioPrice = nights * 50 * 0.95; apartmentPrice = nights * 65; } else if (nights > 14) { studioPrice = nights * 50 * 0.70; apartmentPrice = nights * 65 * 0.90; } System.out.printf("Apartment: %.2f lv.%n", apartmentPrice); System.out.printf("Studio: %.2f lv.", studioPrice); break; case "June": case "September": if (nights <= 14) { studioPrice = nights * 75.20; apartmentPrice = nights * 68.70; } else if (nights > 14) { studioPrice = nights * 75.20 * 0.80; apartmentPrice = nights * 68.70 * 0.90; } System.out.printf("Apartment: %.2f lv.%n", apartmentPrice); System.out.printf("Studio: %.2f lv.", studioPrice); break; case "July": case "August": if (nights <= 14) { studioPrice = nights * 76; apartmentPrice = nights * 77; } else if (nights > 14) { studioPrice = nights * 76; apartmentPrice = nights * 77 * 0.90; } System.out.printf("Apartment: %.2f lv.%n", apartmentPrice); System.out.printf("Studio: %.2f lv.", studioPrice); break; } } }
Mersi mnogo