Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P04_MatchTickets {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double budget = Double.parseDouble(scan.nextLine());
- String category = scan.nextLine();
- int people = Integer.parseInt(scan.nextLine());
- if(people >= 1 && people <= 4){
- budget *= 0.25;
- }
- else if(people >= 5 && people <= 9){
- budget *= 0.4;
- }
- else if(people >= 10 && people <= 24){
- budget *= 0.5;
- }
- else if(people >= 25 && people <= 49){
- budget *= 0.6;
- }
- else{
- budget *= 0.75;
- }
- double singleTicketPrice = 499.99;
- if(category.equals("Normal")) singleTicketPrice = 249.99;
- double neededMoney = singleTicketPrice * people;
- double diff = Math.abs(budget - neededMoney);
- if(neededMoney <= budget){
- System.out.printf("Yes! You have %.2f leva left.",
- diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", diff);
- }
- }
- }
Add Comment
Please, Sign In to add comment