galinyotsev123

ProgBasics04Nested-Statements-P10matchTickets

Jan 6th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P10matchTickets {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double budget = Double.parseDouble(scanner.nextLine());
  8. String category = scanner.nextLine(); //VIP" или "Normal".
  9. int fans = Integer.parseInt(scanner.nextLine());
  10.  
  11. double priceForTickets = 0;
  12. double priceForTransport = 0;
  13.  
  14. if (category.equalsIgnoreCase("VIP")) {
  15. priceForTickets = 499.99 * fans;
  16. } else if (category.equalsIgnoreCase("Normal")) {
  17. priceForTickets = 249.99 * fans;
  18. }
  19.  
  20. if (fans >= 1 && fans <= 4) {
  21. priceForTransport = (budget * 75) / 100;
  22. } else if (fans >= 5 && fans <= 9) {
  23. priceForTransport = (budget * 60) / 100;
  24. } else if (fans >= 10 && fans <= 24) {
  25. priceForTransport = (budget * 50) / 100;
  26. } else if (fans >= 25 && fans <= 49) {
  27. priceForTransport = (budget * 40) / 100;
  28. } else if (fans >= 50) {
  29. priceForTransport = (budget * 25) / 100;
  30. }
  31.  
  32. double total = (priceForTickets + priceForTransport);
  33.  
  34. if (total <= budget) {
  35. System.out.printf("Yes! You have %.2f leva left.", budget - total);
  36. } else {
  37. System.out.printf("Not enough money! You need %.2f leva.", total - budget);
  38. }
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment