Хотелска стая/ Hotel Room JAVA, някой ако може да помогне, че judge mi 50/100, малко ми е дълаг кода.
import java.util.Scanner; public class HotelRoom { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String month = scanner.nextLine(); int countOnNigth = Integer.parseInt(scanner.nextLine()); //• На първия ред е месецът – May, June, July, August, September или October double priceApartament = 0; double priceStudio = 0; if (countOnNigth > 14 && month.equals("May") || month.equals("October")) { priceApartament = countOnNigth * 65.0; priceApartament = priceApartament - 0.10 * priceApartament; System.out.printf("Apartment: %.2f lv.", priceApartament); System.out.println(); }else if (month.equals("May") || month.equals("October")){ priceApartament = countOnNigth * 65.0; System.out.printf("Apartment: %.2f lv.", priceApartament); } if (countOnNigth > 7 && countOnNigth <= 14 && month.equals("May") || month.equals("October")) { priceStudio = countOnNigth * 50; priceStudio = priceStudio - 0.05 * priceStudio; System.out.printf("Studio: %.2f lv.", priceStudio); } if (countOnNigth > 14 && month.equals("May") || month.equals("October")) { priceStudio = countOnNigth * 50; priceStudio = priceStudio - 0.30 * priceStudio; System.out.printf("Studio: %.2f lv.", priceStudio); }else if (month.equals("May") || month.equals("October")){ priceStudio = countOnNigth * 50; System.out.printf("Studio: %.2f lv.", priceStudio); } if (countOnNigth > 14 && month.equals("June")|| month.equals("September")){ priceApartament = countOnNigth * 68.70; priceApartament = priceApartament - 0.10 * priceApartament; System.out.printf("Apartment: %.2f lv.", priceApartament); System.out.println(); }else if (month.equals("June")|| month.equals("September")){ priceApartament = countOnNigth * 68.70; System.out.printf("Apartment: %.2f lv.", priceApartament); System.out.println(); } if (countOnNigth > 14 && month.equals("June") || month.equals("September")){ priceStudio = countOnNigth * 75.20; priceStudio = priceStudio - 0.20 * priceStudio; System.out.printf("Studio: %.2f lv.", priceStudio); }else if (month.equals("June") || month.equals("September")){ priceStudio = countOnNigth * 75.20; System.out.printf("Studio: %.2f lv.", priceStudio); }if (countOnNigth > 14 && month.equals("July")|| month.equals("August")){ priceApartament = countOnNigth * 77.0; priceApartament = priceApartament - 0.10 * priceApartament; System.out.printf("Apartment: %.2f lv.", priceApartament); System.out.println(); }else if (month.equals("July")|| month.equals("August")){ priceApartament = countOnNigth * 77.0; System.out.printf("Apartment: %.2f lv.", priceApartament); System.out.println(); } if (month.equals("July")|| month.equals("August")){ priceStudio = countOnNigth * 76.0; System.out.printf("Studio: %.2f lv.", priceStudio); } } }
Здравей и аз имам подобен проблем 50/100 ми дава judge https://pastebin.com/c4aNxEnT. Ще съм благодарен ако някой може да го погледне
Здравей,
Ето кода ти поправен, дава 100/100. Имаше грешки в граничните стойности и в някои проверки. Принтирането е добре да е само накрая, а не във всеки If:
https://pastebin.com/7fjrqsFC
Много благодаря