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