veronikaaa86

05. Small Shop

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