Advertisement
veronikaaa86

05. Small Shop

Mar 12th, 2022
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. package advancedConditionalStatements;
  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 (town.equals("Sofia")) {
  15. if (product.equals("coffee")) {
  16. price = 0.50;
  17. } else if (product.equals("water")) {
  18. price = 0.80;
  19. } else if (product.equals("beer")) {
  20. price = 1.20;
  21. } else if (product.equals("sweets")) {
  22. price = 1.45;
  23. } else if (product.equals("peanuts")) {
  24. price = 1.60;
  25. }
  26. } else if (town.equals("Plovdiv")) {
  27. if (product.equals("coffee")) {
  28. price = 0.40;
  29. } else if (product.equals("water")) {
  30. price = 0.70;
  31. } else if (product.equals("beer")) {
  32. price = 1.15;
  33. } else if (product.equals("sweets")) {
  34. price = 1.30;
  35. } else if (product.equals("peanuts")) {
  36. price = 1.50;
  37. }
  38. } else if (town.equals("Varna")) {
  39. if (product.equals("coffee")) {
  40. price = 0.45;
  41. } else if (product.equals("water")) {
  42. price = 0.70;
  43. } else if (product.equals("beer")) {
  44. price = 1.10;
  45. } else if (product.equals("sweets")) {
  46. price = 1.35;
  47. } else if (product.equals("peanuts")) {
  48. price = 1.55;
  49. }
  50. }
  51.  
  52. double sum = quantity * price;
  53.  
  54. System.out.println(sum);
  55. }
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement