Advertisement
MladenKarachanov

Untitled

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