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