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 movieName = scanner.nextLine(),
- typeOfHall = scanner.nextLine();
- int ticketCount = Integer.parseInt(scanner.nextLine());
- double ticketPrice = 0;
- if (movieName.equals("A Star Is Born")) {
- if (typeOfHall.equals("normal")) {
- ticketPrice = 7.50;
- } else if (typeOfHall.equals("luxury")) {
- ticketPrice = 10.50;
- } else if (typeOfHall.equals("ultra luxury")) {
- ticketPrice = 13.50;
- }
- } else if (movieName.equals("Bohemian Rhapsody")) {
- if (typeOfHall.equals("normal")) {
- ticketPrice = 7.35;
- } else if (typeOfHall.equals("luxury")) {
- ticketPrice = 9.45;
- } else if (typeOfHall.equals("ultra luxury")) {
- ticketPrice = 12.75;
- }
- } else if (movieName.equals("Green Book")) {
- if (typeOfHall.equals("normal")) {
- ticketPrice = 8.15;
- } else if (typeOfHall.equals("luxury")) {
- ticketPrice = 10.25;
- } else if (typeOfHall.equals("ultra luxury")) {
- ticketPrice = 13.25;
- }
- } else if (movieName.equals("The Favourite")) {
- if (typeOfHall.equals("normal")) {
- ticketPrice = 8.75;
- } else if (typeOfHall.equals("luxury")) {
- ticketPrice = 11.55;
- } else if (typeOfHall.equals("ultra luxury")) {
- ticketPrice = 13.95;
- }
- }
- System.out.printf("%s -> %.2f lv.\n", movieName, ticketPrice * ticketCount);
- }
- }
- ИЛИ:
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String movieName = scanner.nextLine(),
- typeOfHall = scanner.nextLine();
- int ticketCount = Integer.parseInt(scanner.nextLine());
- double ticketPrice = switch (movieName) {
- case "A Star Is Born" -> switch (typeOfHall) {
- case "normal" -> 7.50;
- case "luxury" -> 10.50;
- case "ultra luxury" -> 13.50;
- default -> 0;
- };
- case "Bohemian Rhapsody" -> switch (typeOfHall) {
- case "normal" -> 7.35;
- case "luxury" -> 9.45;
- case "ultra luxury" -> 12.75;
- default -> 0;
- };
- case "Green Book" -> switch (typeOfHall) {
- case "normal" -> 8.15;
- case "luxury" -> 10.25;
- case "ultra luxury" -> 13.25;
- default -> 0;
- };
- case "The Favourite" -> switch (typeOfHall) {
- case "normal" -> 8.75;
- case "luxury" -> 11.55;
- case "ultra luxury" -> 13.95;
- default -> 0;
- };
- default -> 0;
- };
- System.out.printf("%s -> %.2f lv.\n", movieName, ticketPrice * ticketCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement