Advertisement
yovkovbpfps

EXAM 20 - 21 APRIL Easter Party

Apr 26th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class EasterParty {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int guestNum = Integer.parseInt(scanner.nextLine());
  8. double priceOne = Double.parseDouble(scanner.nextLine());
  9. double budgetDesy = Double.parseDouble(scanner.nextLine());
  10.  
  11. if (guestNum >=10&&guestNum<=15)
  12. {
  13. priceOne = priceOne - priceOne * 0.15;
  14. }
  15. else if (guestNum >=15 && guestNum<=20)
  16. {
  17. priceOne = priceOne - priceOne * 0.20;
  18. } else if (guestNum >= 20)
  19. {
  20. priceOne = priceOne - priceOne * 0.25;
  21. }
  22.  
  23. double cakePrice = budgetDesy / 10;
  24. double finalSum = guestNum * priceOne + cakePrice;
  25. double residue = finalSum - budgetDesy;
  26.  
  27. if (finalSum > budgetDesy){
  28. System.out.printf("No party! %.2f leva needed.",Math.abs(residue));
  29. } else {
  30. System.out.printf("It is party time! %.2f leva left.",Math.abs(residue));
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement