Advertisement
PIBogdanov

test

Jan 23rd, 2023
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. package MoreComplexChecks_Lecture;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P11FruitShop
  6. {
  7. public static void main(String[] args)
  8. {
  9. Scanner scanner = new Scanner(System.in);
  10.  
  11. String fruit = scanner.nextLine();
  12. String dayOfWeek = scanner.nextLine();
  13. double count = Double.parseDouble(scanner.nextLine());
  14.  
  15. boolean workingDays = dayOfWeek.equals("Monday") || dayOfWeek.equals("Tuesday") || dayOfWeek.equals("Wednesday") ||
  16. dayOfWeek.equals("Thursday") || dayOfWeek.equals("Friday");
  17. boolean restDays = dayOfWeek.equals("Saturday") || dayOfWeek.equals("Sunday");
  18.  
  19. double price = 0;
  20.  
  21. if (workingDays)
  22. {
  23. if (fruit.equals("banana")) {
  24. price = 2.50;}
  25. } else if (fruit.equals("apple")) {
  26. price = 1.20;
  27. } else if (fruit.equals("orange")) {
  28. price = 0.85;
  29. } else if (fruit.equals("grapefruit")) {
  30. price = 1.45;
  31. } else if (fruit.equals("kiwi")) {
  32. price = 2.70;
  33. } else if (fruit.equals("pineapple")) {
  34. price = 5.50;
  35. } else if (fruit.equals("grapes")) {
  36. price = 3.85;
  37. } else if (restDays)
  38. {
  39. if (fruit.equals("banana")) {
  40. price = 2.70;}
  41. } else if (fruit.equals("apple")) {
  42. price = 1.25;
  43. } else if (fruit.equals("orange")) {
  44. price = 0.90;
  45. } else if (fruit.equals("grapefruit")) {
  46. price = 1.60;
  47. } else if (fruit.equals("kiwi")) {
  48. price = 3;
  49. } else if (fruit.equals("pineapple")) {
  50. price = 5.60;
  51. } else if (fruit.equals("grapes")) {
  52. price = 4.20;
  53. }} else {
  54. System.out.println("error");
  55. }
  56.  
  57. double total = price * count;
  58. System.out.printf("%.2f",total);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement