Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Ex3 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- String category = scanner.nextLine();
- double people = Double.parseDouble(scanner.nextLine());
- double leftmoney = 0;
- double Normal = 249.99;
- double VIP = 499.99;
- if (category.equalsIgnoreCase("Normal")) {
- if (people >= 1 && people <= 4) {
- leftmoney = budget - (budget * 0.75);
- if (leftmoney >= (Normal*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
- }
- } else if (people >= 5 && people <= 9) {
- leftmoney = budget - (budget * 0.60);
- if (leftmoney >= (Normal*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
- }
- } else if (people >= 10 && people <= 24) {
- leftmoney = budget - (budget * 0.50);
- if (leftmoney >= (Normal*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
- }
- } else if (people >= 25 && people <= 49) {
- leftmoney = budget - (budget * 0.40);
- if (leftmoney >= (Normal*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
- }
- } else if (people >= 50) {
- leftmoney = budget - (budget * 0.25);
- if (leftmoney >= (Normal*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
- }
- }
- } else if (category.equalsIgnoreCase("VIP")) {
- if (people >= 1 && people <= 4) {
- leftmoney = budget - (budget * 0.75);
- if (leftmoney >= (VIP*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
- }
- } else if (people >= 5 && people <= 9) {
- leftmoney = budget - (budget * 0.60);
- if (leftmoney >= (VIP*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
- }
- } else if (people >= 10 && people <= 24) {
- leftmoney = budget - (budget * 0.50);
- if (leftmoney >= (VIP*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
- }
- } else if (people >= 25 && people <= 49) {
- leftmoney = budget - (budget * 0.40);
- if (leftmoney >= (VIP*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
- }
- } else if (people >= 50) {
- leftmoney = budget - (budget * 0.25);
- if (leftmoney >= (VIP*people)) {
- System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement