Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class MatchTickets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String ticketType = scanner.nextLine();
- int peopleCount = Integer.parseInt(scanner.nextLine());
- double VIP = 499.99;
- double Normal = 249.99;
- double transportPercentage = 0;
- double ticketsBudget = 0;
- if (peopleCount >= 1 && peopleCount <= 4) {
- transportPercentage = 0.75;
- } else if (peopleCount >=5 && peopleCount <= 9) {
- transportPercentage = 0.60;
- } else if (peopleCount >= 10 && peopleCount <= 24) {
- transportPercentage = 0.50;
- } else if (peopleCount >= 25 && peopleCount <= 49) {
- transportPercentage = 0.40;
- } else if (peopleCount >= 50) {
- transportPercentage = 0.25;
- }
- ticketsBudget = budget - (budget * transportPercentage);
- double ticketsPrice = 0;
- if (ticketType.equalsIgnoreCase("vip")) {
- ticketsPrice = peopleCount * VIP;
- } else if (ticketType.equalsIgnoreCase("normal")) {
- ticketsPrice = peopleCount * Normal;
- }
- double priceDifferences = ticketsBudget - ticketsPrice;
- if (priceDifferences >=0) {
- System.out.printf("Yes! You have %.2f leva left.", priceDifferences);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(priceDifferences));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment