Advertisement
veronikaaa86

05. Small Shop

Oct 16th, 2021
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. package conditionalStatementsAdvanced;
  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.  
  27. } else if (town.equals("Plovdiv")) {
  28. if (product.equals("coffee")) {
  29. price = 0.40;
  30. } else if (product.equals("water")) {
  31. price = 0.70;
  32. } else if (product.equals("beer")) {
  33. price = 1.15;
  34. } else if (product.equals("sweets")) {
  35. price = 1.30;
  36. } else if (product.equals("peanuts")) {
  37. price = 1.50;
  38. }
  39. } else if (town.equals("Varna")) {
  40. if (product.equals("coffee")) {
  41. price = 0.45;
  42. } else if (product.equals("water")) {
  43. price = 0.70;
  44. } else if (product.equals("beer")) {
  45. price = 1.10;
  46. } else if (product.equals("sweets")) {
  47. price = 1.35;
  48. } else if (product.equals("peanuts")) {
  49. price = 1.55;
  50. }
  51. }
  52.  
  53. double result = price * quantity;
  54.  
  55. System.out.println(result);
  56. }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement