Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Problem03 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- //1. +Етап на първенството – текст - “Quarter final ”, “Semi final” или “Final”
- //2. +Вид на билета – текст - “Standard”, “Premium” или “VIP”
- //3. +Брой билети – цяло число в интервала [1 … 30]
- //4. +Снимка с трофея – символ – 'Y' (да) или 'N' (не)
- String stage = scan.nextLine();
- String ticketType = scan.nextLine();
- int ticketsCnt = Integer.parseInt(scan.nextLine());
- String photo = scan.nextLine();
- boolean hasTax = false;
- if (photo.equals("Y")) {
- hasTax = true;
- }
- double price = 0.0;
- switch (stage) {
- //“Standard”, “Premium” или “VIP”
- case "Quarter final":
- if (ticketType.equals("Standard")) {
- price = 55.50;
- } else if (ticketType.equals("Premium")) {
- price = 105.20;
- } else if (ticketType.equals("VIP")) {
- price = 118.90;
- }
- break;
- case "Semi final":
- if (ticketType.equals("Standard")) {
- price = 75.88;
- } else if (ticketType.equals("Premium")) {
- price = 125.22;
- } else if (ticketType.equals("VIP")) {
- price = 300.40;
- }
- break;
- case "Final":
- if (ticketType.equals("Standard")) {
- price = 110.10;
- } else if (ticketType.equals("Premium")) {
- price = 160.66;
- } else if (ticketType.equals("VIP")) {
- price = 400;
- }
- break;
- }
- double totalPrice = price * ticketsCnt; // 5 * (Final VIP) - 400
- if (totalPrice > 4000) {
- totalPrice = totalPrice - totalPrice * 0.25; // totalPrice * 0.75;
- hasTax = false;
- } else if (totalPrice > 2500) {
- totalPrice = totalPrice - totalPrice * 0.1;// totalPrice * 0.9
- }
- if (hasTax) {
- totalPrice = totalPrice + (ticketsCnt * 40);
- }
- System.out.printf("%.2f", totalPrice);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment