Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SkiBreak {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //1. крайна цена = броя нощувки * цена за нощувка
- //бр нощувки =дни - 1
- //цена за 1 нощувка-> зависи от типа на стаята
- //2.намалението
- //3.оценка
- int days = Integer.parseInt(scanner.nextLine());
- String roomType = scanner.nextLine();
- String grade = scanner.nextLine(); //positive or 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.7;
- } else if (days >= 10 && days <= 15){
- //-35%
- totalPrice = totalPrice * 0.65;
- } else if (days > 15) {
- totalPrice = totalPrice * 0.5 *totalPrice;
- }
- }else if (roomType.equals("president apartment")) {
- if (days<10){
- //-10%
- totalPrice = totalPrice * 0.9;
- } else if (days >= 10 && days <= 15){
- //-15%
- totalPrice = totalPrice * 0.85;
- } else if (days > 15) {
- totalPrice = totalPrice * 0.8;
- }
- }
- if (grade.equals("positive")) {
- totalPrice *=1.25;
- }else if (grade.equals("negative")) {
- totalPrice = totalPrice * 0.9;
- }
- System.out.printf("%.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment