Advertisement
Guest User

Untitled

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