Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package W03ConditionalStatementsAdvanced.Exercise;
- import java.util.Scanner;
- public class P07HotelRoom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int countNights = Integer.parseInt(scanner.nextLine());
- double priceForTheApartment = 0;
- double priceForTheStudio = 0;
- switch (month){
- case "May":
- case "October":
- //Пресмятаме цената за студио и апартамен
- priceForTheApartment = countNights * 65;
- priceForTheStudio = countNights * 50;
- //Проверяваме дали имаме отстъпка спрямо броя нощувки
- if(countNights > 14){
- priceForTheStudio = priceForTheStudio * 0.70;
- priceForTheApartment = priceForTheApartment * 0.90;
- } else if (countNights > 7) {
- priceForTheStudio = priceForTheStudio * 0.95;
- }
- break;
- case "June":
- case "September":
- //Пресмятаме цената за студио и апартамен
- priceForTheApartment = countNights * 68.70;
- priceForTheStudio = countNights * 75.20;
- //Проверяваме дали нощувките са повече от 14 -> правим 20% отстъпка
- if(countNights > 14){
- priceForTheStudio = priceForTheStudio * 0.80;
- priceForTheApartment = priceForTheApartment * 0.90;
- }
- break;
- case "July":
- case "August":
- //Пресмятаме цената за студио и апартамен
- priceForTheApartment = countNights * 77;
- priceForTheStudio = countNights * 76;
- if(countNights > 14){
- priceForTheApartment = priceForTheApartment * 0.90;
- }
- break;
- }
- System.out.printf("Apartment: %.2f lv.%n", priceForTheApartment);
- System.out.printf("Studio: %.2f lv.", priceForTheStudio);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment