Advertisement
veronikaaa86

05. Small Shop

May 21st, 2022
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. package nestedConditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05SmallShop {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String product = scanner.nextLine();
  10. String town = scanner.nextLine();
  11. double quantity = Double.parseDouble(scanner.nextLine());
  12.  
  13. double price = 0;
  14. if (product.equals("coffee")) {
  15. if (town.equals("Sofia")) {
  16. price = 0.50;
  17. } else if (town.equals("Plovdiv")) {
  18. price = 0.40;
  19. } else if (town.equals("Varna")) {
  20. price = 0.45;
  21. }
  22. } else if (product.equals("water")) {
  23. if (town.equals("Sofia")) {
  24. price = 0.80;
  25. } else if (town.equals("Plovdiv")) {
  26. price = 0.70;
  27. } else if (town.equals("Varna")) {
  28. price = 0.70;
  29. }
  30. } else if (product.equals("beer")) {
  31. if (town.equals("Sofia")) {
  32. price = 1.20;
  33. } else if (town.equals("Plovdiv")) {
  34. price = 1.15;
  35. } else if (town.equals("Varna")) {
  36. price = 1.10;
  37. }
  38. } else if (product.equals("sweets")) {
  39. if (town.equals("Sofia")) {
  40. price = 1.45;
  41. } else if (town.equals("Plovdiv")) {
  42. price = 1.30;
  43. } else if (town.equals("Varna")) {
  44. price = 1.35;
  45. }
  46. } else if (product.equals("peanuts")) {
  47. if (town.equals("Sofia")) {
  48. price = 1.60;
  49. } else if (town.equals("Plovdiv")) {
  50. price = 1.50;
  51. } else if (town.equals("Varna")) {
  52. price = 1.55;
  53. }
  54. }
  55.  
  56. double result = price * quantity;
  57. System.out.println(result);
  58. }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement