Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exersises;
- import java.util.Scanner;
- public class Vacation {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int people = Integer.parseInt(sc.nextLine());
- String groupType = sc.nextLine();
- String day = sc.nextLine();
- double price = 0;
- double total = 0;
- switch (groupType) {
- case "Students" -> {
- switch (day) {
- case "Friday" -> price = 8.45;
- case "Saturday" -> price = 9.80;
- case "Sunday" -> price = 10.46;
- }
- total = price * people;
- if (people >= 30) {
- total = total - (total * 0.15);
- }
- }
- case "Business" -> {
- price = switch (day) {
- case "Friday" -> 10.90;
- case "Saturday" -> 15.60;
- case "Sunday" -> 16;
- default -> price;
- };
- total = price * people;
- if (people >= 100) {
- total = total - (10 * price);
- }
- }
- case "Regular" -> {
- price = switch (day) {
- case "Friday" -> 15;
- case "Saturday" -> 20;
- case "Sunday" -> 22.50;
- default -> price;
- };
- total = price * people;
- if (people >= 10 && people <= 20) {
- total = total - (total * 0.15);
- }
- }
- }
- System.out.printf("Total price: %.2f", total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement