CoineTre

JF-ExcBasic03.Vacation

Jan 14th, 2021 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.59 KB | None | 0 0
  1. /*You are given a group of people, type of the group, on which day of the week they are going to stay. Based on that information calculate how much they have to pay and print that price on the console. Use the table below. In each cell is the price for a single person. The output should look like that: "Total price: {price}". The price should be formatted to the second decimal point.
  2. */
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Ex3Vacation {
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         int n = Integer.parseInt(scanner.nextLine());
  10.         String group = scanner.nextLine();
  11.         String day = scanner.nextLine();
  12.         double price = 0.0;
  13.         switch (group) {
  14.             case "Students":
  15.                 switch (day) {
  16.                     case "Friday":
  17.                         price = 8.45;
  18.                         break;
  19.                     case "Saturday":
  20.                         price = 9.80;
  21.                         break;
  22.                     case "Sunday":
  23.                         price = 10.46;
  24.                         break;
  25.                 }
  26.                 break;
  27.             case "Business":
  28.                 switch (day) {
  29.                     case "Friday":
  30.                         price = 10.90;
  31.                         break;
  32.                     case "Saturday":
  33.                         price = 15.60;
  34.                         break;
  35.                     case "Sunday":
  36.                         price = 16;
  37.                         break;
  38.                 }
  39.                 break;
  40.             case "Regular":
  41.                 switch (day) {
  42.                     case "Friday":
  43.                         price = 15;
  44.                         break;
  45.                     case "Saturday":
  46.                         price = 20;
  47.                         break;
  48.                     case "Sunday":
  49.                         price = 22.50;
  50.                         break;
  51.                 }
  52.                 break;
  53.         }
  54.         if (group.equals("Students") && n >= 30) {
  55.             double total = n * price * 0.85;
  56.             System.out.printf("Total price: %.2f",total);
  57.         }else if (group.equals("Business") && n >= 100) {
  58.                double total = n * price - (price * 10);
  59.             System.out.printf("Total price: %.2f",total);
  60.         }else if (group.equals("Regular") && (n >= 10 && n <= 20)) {
  61.                 double total = n * price * 0.95;
  62.             System.out.printf("Total price: %.2f",total);
  63.         }else{
  64.             System.out.printf("Total price: %.2f",n * price);
  65.         }
  66.         }
  67.     }
  68.  
Add Comment
Please, Sign In to add comment