Advertisement
Spocoman

Easter Party

Sep 5th, 2024
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int guests = Integer.parseInt(scanner.nextLine());
  7.         double envelope = Double.parseDouble(scanner.nextLine()),
  8.                 budget = Double.parseDouble(scanner.nextLine()),
  9.                 sum = guests * envelope;
  10.  
  11.         if (guests >= 10 && guests <= 15) {
  12.             sum *= 0.85;
  13.         } else if (guests > 15 && guests <= 20) {
  14.             sum *= 0.80;
  15.         } else if (guests > 20) {
  16.             sum *= 0.75;
  17.         }
  18.  
  19.         sum += budget / 10;
  20.  
  21.         if (budget >= sum) {
  22.             System.out.printf("It is party time! %.2f leva left.\n", budget - sum);
  23.         } else {
  24.             System.out.printf("No party! %.2f leva needed.\n", sum - budget);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement