Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class work {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scan.nextLine());
  8.         String room = scan.nextLine();
  9.         String rating = scan.nextLine();
  10.  
  11.         double sum = 0.0;
  12.  
  13.         switch (room){
  14.             case "room for one person":
  15.                 sum = (days - 1) * 18;
  16.  
  17.                 if (rating.equals("positive")){
  18.                     sum += (sum*0.25);
  19.                 }else if (rating.equals("negative")){
  20.                     sum -= (sum*0.10);
  21.                 }
  22.                 break;
  23.  
  24.             case "apartment":
  25.                 sum = (days - 1) * 25;
  26.  
  27.                 if (days < 10){
  28.                     sum *= 0.70;
  29.                 }else if (days <= 15){
  30.                     sum *= 0.65;
  31.                 }else {
  32.                     sum *= 50;
  33.                 }
  34.  
  35.                 if (rating.equals("positive")){
  36.                     sum += (sum*0.25);
  37.                 }else if (rating.equals("negative")){
  38.                     sum -= (sum*0.10);
  39.                 }
  40.  
  41.                 break;
  42.  
  43.             case "president apartment":
  44.                 sum = (days - 1) * 35;
  45.  
  46.                 if (days < 10){
  47.                     sum *= 0.90;
  48.                 }else if (days <= 15){
  49.                     sum *= 0.85;
  50.                 }else {
  51.                     sum *= 0.80;
  52.                 }
  53.  
  54.                 if (rating.equals("positive")){
  55.                     sum += (sum*0.25);
  56.                 }else if (rating.equals("negative")){
  57.                     sum -= (sum*0.10);
  58.                 }
  59.         }
  60.         System.out.printf("%.2f", sum);
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement