desislava_topuzakova

Untitled

Mar 14th, 2022
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. package ConditionalStatements;
  2.  
  3. import java.sql.SQLOutput;
  4. import java.util.Scanner;
  5.  
  6. public class GodzillaVsKong {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. //Ред 1. Бюджет за филма – реално число в интервала [1.00 … 1000000.00]
  11. //Ред 2. Брой на статистите – цяло число в интервала [1 … 500]
  12. //Ред 3. Цена за облекло на един статист – реално число в интервала [1.00 … 1000.00]
  13.  
  14. double budget = Double.parseDouble(scanner.nextLine());
  15. int walkOn = Integer.parseInt(scanner.nextLine());
  16. double priceForClothesForOne = Double.parseDouble(scanner.nextLine());
  17.  
  18. double decor = budget * 0.10;
  19.  
  20. if (walkOn >= 150) {
  21. priceForClothesForOne = priceForClothesForOne - (priceForClothesForOne * 0.10) ;
  22. }
  23. double moneyForClothes = priceForClothesForOne * walkOn;
  24. if (decor + moneyForClothes > budget) {
  25. double neededMoney = Math.abs(budget - decor - moneyForClothes);
  26.  
  27. System.out.println("Not enough money!");
  28. System.out.printf("Wingard needs %.2f leva more." , neededMoney);
  29. } else if (decor + moneyForClothes <= budget) {
  30. double neededMoney = Math.abs(budget - decor - moneyForClothes) ;
  31.  
  32. System.out.println("Action!" );
  33. System.out.printf ("Wingard starts filming with %.2f leva left.", neededMoney);
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment