borkins

Exam 17-Jul-2016 - 03. Match Tickets

May 16th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. /**
  2.  * Project: Exam_17_July_2016 - created by borkins on 2017-05-16.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _03_MatchTickets
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner console = new Scanner(System.in);
  12.        
  13.         double budget = Double.parseDouble(console.nextLine());
  14.         String category = console.nextLine();
  15.         int peoples = Integer.parseInt(console.nextLine());
  16.        
  17.         boolean isVIP = (category.equalsIgnoreCase("vip"));
  18.         double ticketPrice = ((isVIP) ? 499.99 : 249.99) * peoples;
  19.        
  20.         if (peoples < 5) budget -= budget * 0.75;
  21.         else if (peoples < 10) budget -= budget * 0.60;
  22.         else if (peoples < 25) budget -= budget * 0.50;
  23.         else if (peoples < 50) budget -= budget * 0.40;
  24.         else budget -= budget * 0.25;
  25.        
  26.         double diffMoney = Math.abs(budget - ticketPrice);
  27.        
  28.         if (budget >= ticketPrice)
  29.         {
  30.             System.out.printf("Yes! You have %.2f leva left.", diffMoney);
  31.         }
  32.         else {
  33.             System.out.printf("Not enough money! You need %.2f leva.", diffMoney);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment