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