Advertisement
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(); // "march", "april", "may", "june", "july", "august"
- int numberHours = Integer.parseInt(scanner.nextLine());
- int numberPerson = Integer.parseInt(scanner.nextLine());
- String tomeDay = scanner.nextLine(); // "day" или "night"
- double price = 0;
- if ((month.equals("march") || (month.equals("april") || (month.equals("may"))))){
- if(tomeDay.equals("day")){
- price = 10.50;
- if(numberPerson >= 4){
- price = 10.50 - 0.10;
- }
- if(numberHours >= 5){
- price = 10.50 - 0.50;
- }
- double totalPrice = (price * numberPerson) * numberHours;
- System.out.printf("Price per person for one hour: %.2f%n",price);
- System.out.printf("Total cost of the visit: %.2f",totalPrice);
- }
- }else if ((month.equals("june") || (month.equals("july") || (month.equals("august"))))){
- if(tomeDay.equals("day")){
- price = 12.60;
- if(numberPerson >= 4){
- price =12.60 - 0.10;
- }
- if(numberHours >= 5){
- price = 12.60 - 0.50;
- }
- double totalPrice = (price * numberPerson) * numberHours;
- System.out.printf("Price per person for one hour: %.2f%n",price);
- System.out.printf("Total cost of the visit: %.2f",totalPrice);
- }else if(tomeDay.equals("night")){
- price = 10.20;
- if(numberPerson >= 4){
- price =10.20 - 0.9;
- //double sum = price;
- }
- if(numberHours >= 5){
- price = price - 0.5;
- }
- double totalPrice = (price * numberPerson) * numberHours;
- System.out.printf("Price per person for one hour: %.2f%n",price);
- System.out.printf("Total cost of the visit: %.2f",totalPrice);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement