galinyotsev123

ProgBasicsJavaBook4.1ComplexConditions02SmallShop

Jan 18th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E02SmallShop {
  4. public static void main(String[] Arg) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8. String product = scanner.nextLine().toLowerCase();
  9. String city = scanner.nextLine().toLowerCase();
  10. double quantity = Double.parseDouble(scanner.nextLine());
  11. double Totalprice = 0;
  12.  
  13. if (city.equals("sofia")) {
  14. if (product.equals("coffee")) {
  15. Totalprice = 0.50 * quantity;
  16. } else if (product.equals("water")) {
  17. Totalprice = 0.80 * quantity;
  18. } else if (product.equals("beer")) {
  19. Totalprice = 1.20 * quantity;
  20. } else if (product.equals("sweets")) {
  21. Totalprice = 1.45 * quantity;
  22. } else if (product.equals("peanuts")) {
  23. Totalprice = 1.60 * quantity;
  24. }
  25. } else if (city.equals("plovdiv")) {
  26. if (product.equals("coffee")) {
  27. Totalprice = 0.40 * quantity;
  28. } else if (product.equals("water")) {
  29. Totalprice = 0.70 * quantity;
  30. } else if (product.equals("beer")) {
  31. Totalprice = 1.15 * quantity;
  32. } else if (product.equals("sweets")) {
  33. Totalprice = 1.30 * quantity;
  34. } else if (product.equals("peanuts")) {
  35. Totalprice = 1.50 * quantity;
  36. }
  37. } else if (city.equals("varna")) {
  38. if (product.equals("coffee")) {
  39. Totalprice = 0.45 * quantity;
  40. } else if (product.equals("water")) {
  41. Totalprice = 0.70 * quantity;
  42. } else if (product.equals("beer")) {
  43. Totalprice = 1.10 * quantity;
  44. } else if (product.equals("sweets")) {
  45. Totalprice = 1.35 * quantity;
  46. } else if (product.equals("peanuts")) {
  47. Totalprice = 1.55 * quantity;
  48. }
  49. }
  50. System.out.println(Totalprice);
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment