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