Angel_Kalinkov

PBE-17July2016-MatchTickets2_AngelKalinkov

Feb 21st, 2018
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MatchTickets2 {
  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().toLowerCase();
  9.         int people = Integer.parseInt(scanner.nextLine());
  10.  
  11.         double ticketPrice = 249.99;
  12.         double transportCosts;
  13.  
  14.         if (ticketType.equals("vip")) {
  15.             ticketPrice = 499.99;
  16.         }
  17.         if (people <= 4){
  18.             transportCosts = budget * 0.75;
  19.         } else if (people <= 9) {
  20.             transportCosts = budget * 0.60;
  21.         } else if (people <= 24) {
  22.             transportCosts = budget * 0.50;
  23.         } else if (people <= 49) {
  24.             transportCosts = budget * 0.40;
  25.         } else {
  26.             transportCosts = budget * 0.25;
  27.         }
  28.         double moneyForTickets = people * ticketPrice;
  29.         double moneyDifference = budget - (moneyForTickets + transportCosts);
  30.  
  31.         String output = String.format("Yes! You have %.2f leva left.", moneyDifference);
  32.         if (moneyDifference < 0) {
  33.             output = String.format("Not enough money! You need %.2f leva.", Math.abs(moneyDifference));
  34.         }
  35.         System.out.println(output);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment