Софтуерно Инженерство
Loading...
+ Нов въпрос
The_assassin avatar The_assassin 158 Точки

Тя е почти същата като „7. Навреме за изпит“, какво точно те затруднява?

0
nikeza avatar nikeza 2 Точки

И аз нещо не стигнах до никъде с тази задача, джъджа ми дава 60/100 с моето решение, къде ми е грешката :

 

String month = scanner.nextLine();
        int night = Integer.parseInt(scanner.nextLine());

        double studioMayOctober = 50.00;
        double studioJunSeptember = 75.20;
        double studioJulAugust = 76.00;

        double apartmentMayOctomber = 65.00;
        double apartmentJunSeptember = 68.70;
        double apartmentJulAugust = 77.00;

        double priceStudio = 0;
        double priceApartment = 0;


        switch (month) {
            case "May":
                priceStudio = studioMayOctober;
                priceApartment = apartmentMayOctomber;
                break;
            case "October":
                priceStudio = studioMayOctober;
                priceApartment = apartmentMayOctomber;
                break;
            case "June":
                priceStudio = studioJunSeptember;
                priceApartment = apartmentJunSeptember;
                break;
            case "September":
                priceStudio = studioJunSeptember;
                priceApartment = apartmentJunSeptember;
                break;
            case "July ":
                priceStudio = studioJulAugust;
                priceApartment = apartmentJulAugust;
                break;
            case "August":
                priceStudio = studioJulAugust;
                priceApartment = apartmentJulAugust;
                break;
        }

        double discountStudio = 0;

        if ("May".equals(month) || "October".equals(month)) {
            if (night <= 6) {
                discountStudio = 1.0;
            } else if (night <= 14) {
                discountStudio = 0.95;
            } else {
                discountStudio = 0.7;
            }
        } else if ("June".equals(month) || "September ".equals(month)) {
            if (night > 14) {
                discountStudio = 0.80;
            } else
                discountStudio = 1.0;
        } else {
            discountStudio = 1;

        }


        double discountApartment = 1;

        if (night > 14){
            discountApartment = 0.9;
        }



        double finalPriceStudio = priceStudio * discountStudio * night;
        double finalPriceApartment = priceApartment * discountApartment * night;

        System.out.printf("Apartment: %.2f lv. " +
                "%nStudio: %.2f lv.", finalPriceApartment, finalPriceStudio);


    }
}
0
nikeza avatar nikeza 2 Точки

Оправих се, няколко спейса в повече и една буква различна ..

0