tsveten_kavrakov

08.HotelRoom

Feb 20th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class LabTest {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.  
  7.         String month=sc.nextLine();
  8.         int overnights=Integer.parseInt(sc.nextLine());
  9.         double appartmentRent=0;
  10.         double appartmentDiscount=0;
  11.         double studioRent=0;
  12.         double studioDiscount=0;
  13.  
  14.         switch(month){
  15.             case "May":
  16.             case "October":
  17.                 studioRent=50.00;
  18.                 appartmentRent=65.00;
  19.                 if (overnights>14){
  20.                     studioDiscount=30;
  21.                 }else if (overnights>7){
  22.                     studioDiscount=5;
  23.                 }
  24.                 break;
  25.             case "June":
  26.             case "September":
  27.                 studioRent=75.20;
  28.                 appartmentRent=68.70;
  29.                 if (overnights>14){
  30.                     studioDiscount=20;
  31.                 }
  32.                 break;
  33.             case "July":
  34.             case "August":
  35.                 studioRent=76.00;
  36.                 appartmentRent=77.00;
  37.                 break;
  38.         }
  39.         if (overnights>14){
  40.             appartmentDiscount=10;
  41.         }
  42.  
  43.         double studioPrice=overnights*studioRent*(100-studioDiscount)/100;
  44.         double appartmenttPrice=overnights*appartmentRent*(100-appartmentDiscount)/100;
  45.  
  46.         System.out.printf("Apartment: %.2f lv.%nStudio: %.2f lv.",appartmenttPrice,studioPrice);
  47.  
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment