Helena12

Match Tickets

Oct 29th, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MatchTickets {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double budget = Double.parseDouble(scanner.nextLine());
  8.         String ticketType = scanner.nextLine();
  9.         int peopleCount = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double VIP = 499.99;
  12.         double Normal = 249.99;
  13.         double transportPercentage = 0;
  14.         double ticketsBudget = 0;
  15.  
  16.         if (peopleCount >= 1 && peopleCount <= 4) {
  17.             transportPercentage = 0.75;
  18.         } else if (peopleCount >=5 && peopleCount <= 9) {
  19.             transportPercentage = 0.60;
  20.         } else if (peopleCount >= 10 && peopleCount <= 24) {
  21.             transportPercentage = 0.50;
  22.         } else if (peopleCount >= 25 && peopleCount <= 49) {
  23.             transportPercentage = 0.40;
  24.         } else if (peopleCount >= 50) {
  25.             transportPercentage = 0.25;
  26.         }
  27.         ticketsBudget = budget - (budget * transportPercentage);
  28.         double ticketsPrice = 0;
  29.         if (ticketType.equalsIgnoreCase("vip")) {
  30.             ticketsPrice = peopleCount * VIP;
  31.         } else if (ticketType.equalsIgnoreCase("normal")) {
  32.             ticketsPrice = peopleCount * Normal;
  33.         }
  34.         double priceDifferences = ticketsBudget - ticketsPrice;
  35.         if (priceDifferences >=0) {
  36.             System.out.printf("Yes! You have %.2f leva left.", priceDifferences);
  37.         } else  {
  38.             System.out.printf("Not enough money! You need %.2f leva.", Math.abs(priceDifferences));
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment