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