Advertisement
markov5534

shop final

Nov 21st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class shop {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7.  
  8.  
  9. System.out.print("What product? : ");
  10. String product = scanner.nextLine();
  11.  
  12. System.out.print("Which town? : ");
  13. String town = scanner.nextLine();
  14. town = town.substring(0, 1).toUpperCase()+ town.substring(1).toLowerCase();
  15.  
  16.  
  17. System.out.print("How much? : ");
  18. double amount = Double.parseDouble(scanner.nextLine());
  19. double price;
  20.  
  21.  
  22.  
  23. if (product.equals("coffee") && town.equals("Sofia")) {
  24.  
  25.  
  26. price = amount * 0.50;
  27. System.out.printf("Price: %f\n", price);
  28. } else if (product.equals("coffee") && town.equals("Plovdiv")) {
  29.  
  30. price = amount * 0.40;
  31. System.out.printf("Price: %f\n", price);
  32. } else if (product.equals("coffee") && town.equals("Varna")) {
  33.  
  34. price = amount * 0.45;
  35. System.out.printf("Price: %f\n", price);
  36. } else if (product.equals("water") && town.equals("Sofia")) {
  37.  
  38. price = amount * 0.80;
  39. System.out.printf("Price: %f\n", price);
  40. } else if (product.equals("water") && town.equals("Plovdiv")) {
  41.  
  42. price = amount * 0.70;
  43. System.out.printf("Price: %f\n", price);
  44. } else if (product.equals("water") && town.equals("Varna")) {
  45.  
  46. price = amount * 0.70;
  47. System.out.printf("Price: %f\n", price);
  48. } else if (product.equals("beer") && town.equals("Sofia")) {
  49.  
  50. price = amount * 1.20;
  51. System.out.printf("Price: %f\n", price);
  52. } else if (product.equals("beer") && town.equals("Varna")) {
  53.  
  54. price = amount * 1.10;
  55. System.out.printf("Price: %f\n", price);
  56. } else if (product.equals("beer") && town.equals("Plovdiv")) {
  57.  
  58. price = amount * 1.15;
  59. System.out.printf("Price: %f\n", price);
  60. } else if (product.equals("sweets") && town.equals("Sofia")) {
  61.  
  62. price = amount * 1.45;
  63. System.out.printf("Price: %f\n", price);
  64. } else if (product.equals("sweets") && town.equals("Plovdiv")) {
  65.  
  66. price = amount * 1.30;
  67. System.out.printf("Price: %f\n", price);
  68. } else if (product.equals("sweets") && town.equals("Varna")) {
  69.  
  70. price = amount * 1.35;
  71. System.out.printf("Price: %f\n", price);
  72. } else if (product.equals("peanuts") && town.equals("Sofia")) {
  73.  
  74. price = amount * 1.60;
  75. System.out.printf("Price: %f\n", price);
  76. } else if (product.equals("peanuts") && town.equals("Plovdiv")) {
  77.  
  78. price = amount * 1.50;
  79. System.out.printf("Price: %f\n", price);
  80. } else if (product.equals("peanuts") && town.equals("Varna")) {
  81.  
  82. price = amount * 1.55;
  83. System.out.printf("Price: %f\n", price);
  84.  
  85.  
  86. }
  87.  
  88.  
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement