Advertisement
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 vipPrice = 499.99;
- double normalPrice = 249.99;
- int budjet = Integer.parseInt(scanner.nextLine());
- String category = scanner.nextLine();
- int peopleNumber= Integer.parseInt(scanner.nextLine());
- double moneyForTickets = -1.0;
- double price = -1.0;
- double difference = -1.0;
- boolean from1To4 = peopleNumber >= 1 && peopleNumber <=4;
- boolean from5To9 = peopleNumber >= 5 && peopleNumber <=9;
- boolean from10To24 = peopleNumber >= 10 && peopleNumber <=24;
- boolean from25To49 = peopleNumber >= 25 && peopleNumber <=49;
- boolean over50 = peopleNumber >= 50;
- if (category.equals("Normal")) {
- if (from1To4) {
- moneyForTickets = budjet - (budjet * 0.75);
- price = peopleNumber * normalPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from5To9) {
- moneyForTickets = budjet - (budjet * 0.60);
- price = peopleNumber * normalPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from10To24) {
- moneyForTickets = budjet - (budjet * 0.50);
- price = peopleNumber * normalPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from25To49) {
- moneyForTickets = budjet - (budjet * 0.40);
- price = peopleNumber * normalPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (over50) {
- moneyForTickets = budjet - (budjet * 0.25);
- price = peopleNumber * normalPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- }
- } else if (category.equals("VIP")) {
- if (from1To4) {
- moneyForTickets = budjet - (budjet * 0.75);
- price = peopleNumber * vipPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from5To9) {
- moneyForTickets = budjet - (budjet * 0.60);
- price = peopleNumber * vipPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from10To24) {
- moneyForTickets = budjet - (budjet * 0.50);
- price = peopleNumber * vipPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (from25To49) {
- moneyForTickets = budjet - (budjet * 0.40);
- price = peopleNumber * vipPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- } else if (over50) {
- moneyForTickets = budjet - (budjet * 0.25);
- price = peopleNumber * vipPrice;
- if (price <= moneyForTickets) {
- difference = moneyForTickets - price;
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
- } else {
- difference = price - moneyForTickets;
- System.out.printf("Not enough money! You need %.2f leva.", difference);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement