Advertisement
Guest User

Untitled

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