Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P10matchTickets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String category = scanner.nextLine(); //VIP" или "Normal".
- int fans = Integer.parseInt(scanner.nextLine());
- double priceForTickets = 0;
- double priceForTransport = 0;
- if (category.equalsIgnoreCase("VIP")) {
- priceForTickets = 499.99 * fans;
- } else if (category.equalsIgnoreCase("Normal")) {
- priceForTickets = 249.99 * fans;
- }
- if (fans >= 1 && fans <= 4) {
- priceForTransport = (budget * 75) / 100;
- } else if (fans >= 5 && fans <= 9) {
- priceForTransport = (budget * 60) / 100;
- } else if (fans >= 10 && fans <= 24) {
- priceForTransport = (budget * 50) / 100;
- } else if (fans >= 25 && fans <= 49) {
- priceForTransport = (budget * 40) / 100;
- } else if (fans >= 50) {
- priceForTransport = (budget * 25) / 100;
- }
- double total = (priceForTickets + priceForTransport);
- if (total <= budget) {
- System.out.printf("Yes! You have %.2f leva left.", budget - total);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", total - budget);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment