Advertisement
veronikaaa86

05. Small Shop

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