Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int hours = Integer.parseInt(scanner.nextLine()),
- people = Integer.parseInt(scanner.nextLine());
- String time = scanner.nextLine();
- double price = 0;
- if (month.equals("march") || month.equals("april") || month.equals("may")) {
- if (time.equals("day")) {
- price = 10.50;
- hours = 3;
- } else {
- price = 8.40;
- }
- } else if (month.equals("june") || month.equals("july") || month.equals("august")) {
- if (time.equals("day")) {
- price = 12.60;
- } else {
- price = 10.20;
- }
- }
- if (people >= 4) {
- price *= 0.9;
- }
- if (hours >= 5) {
- price /= 2;
- }
- double total = price * people * hours;
- System.out.printf("Price per person for one hour: %.2f\n", price);
- System.out.printf("Total cost of the visit: %.2f\n", total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement