Untitled

mail@pastecode.io avatar
unknown
plain_text
3 years ago
2.9 kB
62
Indexable
Never
import com.sun.security.jgss.GSSUtil;

import java.util.Locale;
import java.util.Scanner;

public class demo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //1. крайна цена = бр. нощувки (дни - 1) * цена за 1 нощувка (зависи от типа стая)
        //2. намаление на крайната цена -> вид на стаята и броя нощувки
        //3. намаление спрямо мнението за хотела
        //4. печатаме крайанта цена след намаленията
        int days = Integer.parseInt(scanner.nextLine());
        String typeRoom = scanner.nextLine();
        String grade = scanner.nextLine();

        //крайна цена
        int nights = days - 1;
        double pricePerNight = 0;

        switch (typeRoom) {
            case "room for one person":
                pricePerNight = 18;
                break;
            case "apartment":
                pricePerNight = 25;
                break;
            case "president apartment":
                pricePerNight = 35;
                break;
        }

        double finalSum = nights * pricePerNight;

        //намаление 1
        switch(typeRoom){
            case "apartment":
                if(days  < 10) {
                    finalSum = finalSum - 0.30 * finalSum;
                    //finalSum = 0.7 * finalSum;
                } else if (days >= 10 && days <= 15) {
                    finalSum = finalSum - 0.35 * finalSum;
                    //finalSum = 0.65 * finalSum
                } else if (days > 15){
                    finalSum = finalSum - 0.50 * finalSum;
                    //finalSum = 0.5 * finalSum;
                }
                break;
            case "president apartment":
                if(days  < 10) {
                    finalSum = finalSum - 0.10 * finalSum;
                    //finalSum = 0.9 * finalSum;
                } else if (days >= 10 && days <= 15) {
                    finalSum = finalSum - 0.15 * finalSum;
                    //finalSum = 0.65 * finalSum
                } else if (days > 15){
                    finalSum = finalSum - 0.20 * finalSum;
                    //finalSum = 0.8 * finalSum;
                }
                break;
        }

        //намаление 2 -> оценка -> positive или negative
        if(grade.equals("positive")){
            finalSum = finalSum + 0.25 * finalSum;
            //finalSum = 1.25 * finalSum
        } else if(grade.equals("negative")) {
            finalSum = finalSum - 0.10 * finalSum;
            //finalSum = 0.9 * finalSum;
        }

        System.out.printf("%.2f", finalSum);



    }
}