Advertisement
Guest User

Untitled

a guest
May 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.48 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         Integer groupAmount = Integer.parseInt(scanner.nextLine());
  12.         String groupType = scanner.nextLine();
  13.         String weekday = scanner.nextLine();
  14.  
  15.         Double price= 0.0;
  16.         Double pricePerNight = 0.0;
  17.  
  18.         switch (groupType){
  19.             case "Students":
  20.                 switch (weekday){
  21.                     case "Friday":
  22.                         pricePerNight = 8.45;
  23.                         break;
  24.                     case "Saturday":
  25.                         pricePerNight = 9.8;
  26.                         break;
  27.                     case "Sunday":
  28.                         pricePerNight = 10.46;
  29.                         break;
  30.                 }
  31.  
  32.                 price = groupAmount * pricePerNight;
  33.                 if(groupAmount >= 30){
  34.                     price = price - price * 0.15;
  35.                 }
  36.                 break;
  37.             case "Business":
  38.                 switch (weekday){
  39.                     case "Friday":
  40.                         pricePerNight = 10.90;
  41.                         break;
  42.                     case "Saturday":
  43.                         pricePerNight = 15.6;
  44.                         break;
  45.                     case "Sunday":
  46.                         pricePerNight = 16.0;
  47.                         break;
  48.                 }
  49.                 price = groupAmount * pricePerNight;
  50.                 if(groupAmount >= 100){
  51.                     price = (groupAmount-10) * pricePerNight;
  52.                 }else{
  53.                     price = groupAmount * pricePerNight;
  54.                 }
  55.                 break;
  56.             case "Regular":
  57.                 switch (weekday){
  58.                     case "Friday":
  59.                         pricePerNight = 15.0;
  60.                         break;
  61.                     case "Saturday":
  62.                         pricePerNight = 20.0;
  63.                         break;
  64.                     case "Sunday":
  65.                         pricePerNight = 22.5;
  66.                         break;
  67.                 }
  68.                 price = groupAmount * pricePerNight;
  69.                 if(groupAmount >= 10 && groupAmount <= 20){
  70.                     price = price - price * 0.05;
  71.                 }
  72.                 break;
  73.  
  74.         }
  75.  
  76.         System.out.printf("Total price: %.2f", price);
  77.  
  78.  
  79.  
  80.  
  81.  
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement