Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.util.InvalidPropertiesFormatException;
  3. import java.util.Scanner;
  4. import java.util.function.DoublePredicate;
  5.  
  6. public class FishingBoat {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9. int budget = Integer.parseInt(scanner.nextLine());
  10. String season = scanner.nextLine();
  11. int fishMen = Integer.parseInt(scanner.nextLine());
  12. double Spring = 3000;
  13. double Summer = 4200;
  14. double Autumn = 4200;
  15. double Winter = 2600;
  16. double price = 0;
  17. double priceTotal = 0;
  18.  
  19. switch (season) {
  20. case "Spring":
  21. price = 3000;
  22. break;
  23. case "Summer":
  24. price = 4200;
  25. break;
  26. case "Autumn":
  27. price = 4200;
  28. break;
  29. case "Winter":
  30. price = 2600;
  31. break;
  32. } if (fishMen % 2 == 0 && season == "Spring" + "Summer" + "Winer" ){
  33. price = price * 0.95;
  34. } if (fishMen > 0 && fishMen <= 6) {
  35. priceTotal = price * 0.90;
  36. } else if (fishMen >= 7 && fishMen <= 11 ) {
  37. priceTotal = price *0.85;
  38. }else if (fishMen >= 12){
  39. priceTotal = price * 0.75;
  40. }if (budget >= priceTotal) {
  41. double leftMoney = budget - priceTotal;
  42. System.out.printf("Yes! You have %.2f leva left.", Math.abs(leftMoney));
  43. //"Yes! You have {останалите пари} leva left."
  44. }else{
  45. double needMoney = priceTotal - budget;
  46. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(needMoney));
  47. //"Not enough money! You need {сумата, която не достига} leva."
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement