Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ComputerRoom {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String month = scanner.nextLine();
- int hoursSpend = Integer.parseInt(scanner.nextLine());
- int numberOfPeople = Integer.parseInt(scanner.nextLine());
- String dayTime = scanner.nextLine();
- double pricePerPerson = 0.0;
- double totalPrice = 0.0;
- switch (month) {
- case "march":
- case "april":
- case "may":
- if (dayTime.equals("day")){
- pricePerPerson = 10.50;
- } else if (dayTime.equals("night")){
- pricePerPerson = 8.40;
- }
- break;
- case "june":
- case "july":
- case"august":
- if (dayTime.equals("day")){
- pricePerPerson = 12.60;
- } else if (dayTime.equals("night")){
- pricePerPerson = 10.20;
- }
- break;
- }
- if (numberOfPeople >= 4){
- pricePerPerson = pricePerPerson * 0.90;
- }
- if (hoursSpend >= 5){
- pricePerPerson = pricePerPerson * 0.50;
- }
- totalPrice = (pricePerPerson * numberOfPeople) * hoursSpend;
- System.out.printf("Price per person for one hour: %.2f%n", pricePerPerson);
- System.out.printf("Total cost of the visit: %.2f", totalPrice);
- }
- }
Add Comment
Please, Sign In to add comment