Advertisement
markov5534

Untitled

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