Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SkiTrip_10 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //1. крайна цена = бр. нощувки * цена за 1 нощувка
- //бр.нощувки = дни - 1
- //цена за 1 нощувка -> зависи от типа на стаята
- //2. намалението
- //3. оценка
- int days = Integer.parseInt(scanner.nextLine());
- String roomType = scanner.nextLine(); // "room for one person", "apartment" или "president apartment"
- String grade = scanner.nextLine(); // "positive" или "negative"
- int nights = days - 1; //нощувки
- double pricePerNight = 0;
- //проверка за стаята
- switch (roomType) {
- case "room for one person":
- pricePerNight = 18;
- break;
- case "apartment":
- pricePerNight = 25;
- break;
- case "president apartment":
- pricePerNight = 35;
- break;
- }
- double totalPrice = nights * pricePerNight;
- if (roomType.equals("apartment")) {
- if (days < 10) {
- //-30%
- totalPrice = totalPrice - 0.3 * totalPrice; //0.7 * totalPrice;
- } else if (days >= 10 && days <= 15) {
- //-35%
- totalPrice = totalPrice - 0.35 * totalPrice; //0.65 * totalPrice
- } else if (days > 15) {
- //-50% -> 0.5
- totalPrice = totalPrice - 0.5 * totalPrice;
- }
- } else if (roomType.equals("president apartment")) {
- if (days < 10) {
- //-10%
- totalPrice = totalPrice - 0.1 * totalPrice; //0.9 * totalPrice;
- } else if (days >= 10 && days <= 15) {
- //-15%
- totalPrice = totalPrice - 0.15 * totalPrice; //0.85 * totalPrice
- } else if (days > 15) {
- //-20% -> 0.2
- totalPrice = totalPrice - 0.2 * totalPrice;
- }
- }
- if (grade.equals("positive")){
- totalPrice = totalPrice + 0.25 * totalPrice; //1.25
- } else if (grade.equals("negative")){
- totalPrice = totalPrice - 0.10 * totalPrice;
- }
- System.out.printf("%.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement