Petra_Abrasheva_185

Годишна работа: 4.2-хотелска стая

Jun 4th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         String season = scan.nextLine();
  7.         int nights = Integer.parseInt(scan.nextLine());
  8.         double apartment = 0;
  9.         double studio = 0;
  10.         double studioPrice = 0;
  11.         double apartmentPrice = 0;
  12.         double discountS = 0;
  13.         double discountA = 0;
  14.         if (season.equals("May") || season.equals("October")) {
  15.             studioPrice = 50;
  16.             apartmentPrice = 65;
  17.         } else if (season.equals("June") || season.equals("September")) {
  18.             studioPrice = 75.20;
  19.             apartmentPrice = 68.70;
  20.         } else if (season.equals("July") || season.equals("August")) {
  21.             studioPrice = 76;
  22.             apartmentPrice = 77;
  23.         }
  24.  
  25.         switch(season){
  26.             case "May":
  27.             case "October":
  28.                 if (nights>7){
  29.                     discountS = 0.05 * studioPrice;
  30.                 }if (nights>14){
  31.                 discountS = 0.30 * studioPrice;
  32.             }break;
  33.             case "June":
  34.             case"September":
  35.                 if (nights > 14){
  36.                     discountS = 0.20 * studioPrice;
  37.                 }break;
  38.             default:break;
  39.         }
  40.         if(nights>14){
  41.             discountA = 0.10 * apartmentPrice;
  42.         }
  43.         studioPrice-=discountS;
  44.         apartmentPrice-=discountA;
  45.         studio = studioPrice * nights;
  46.         apartment = apartmentPrice *nights;
  47.  
  48.         System.out.printf("Apartment: %.2f lv.%n",apartment);
  49.          System.out.printf("Studio: %.2f lv.",studio);
  50.     }
  51. }
Add Comment
Please, Sign In to add comment