galinyotsev123

ProgBasicsExam28and29July2018-E03footballSouvenirs

Dec 28th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E03footballSouvenirs {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String country = scanner.nextLine();
  8. String stock = scanner.nextLine();
  9. double quantity = Double.parseDouble(scanner.nextLine());
  10.  
  11. double totalPrice = 0;
  12. double sum = 0;
  13.  
  14.  
  15. if (!(stock.equals("flags") || stock.equals("caps") || stock.equals("posters") || stock.equals("stickers"))) {
  16. System.out.println("Invalid stock!");
  17. return;
  18. }
  19.  
  20. if (country.equalsIgnoreCase("Argentina")) {
  21. if (stock.equalsIgnoreCase("flags")) {
  22. sum = 3.25;
  23. } else if (stock.equalsIgnoreCase("caps")) {
  24. sum = 7.20;
  25. } else if (stock.equalsIgnoreCase("posters")) {
  26. sum = 5.10;
  27. } else if (stock.equalsIgnoreCase("stickers")) {
  28. sum = 1.25;
  29. }
  30. } else if (country.equalsIgnoreCase("Brazil")) {
  31. if (stock.equalsIgnoreCase("flags")) {
  32. sum = 4.20;
  33. } else if (stock.equalsIgnoreCase("caps")) {
  34. sum = 8.50;
  35. } else if (stock.equalsIgnoreCase("posters")) {
  36. sum = 5.35;
  37. } else if (stock.equalsIgnoreCase("stickers")) {
  38. sum = 1.20;
  39. }
  40. } else if (country.equalsIgnoreCase("Croatia")) {
  41. if (stock.equalsIgnoreCase("flags")) {
  42. sum = 2.75;
  43. } else if (stock.equalsIgnoreCase("caps")) {
  44. sum = 6.90;
  45. } else if (stock.equalsIgnoreCase("posters")) {
  46. sum = 4.95;
  47. } else if (stock.equalsIgnoreCase("stickers")) {
  48. sum = 1.10;
  49. }
  50. } else if (country.equalsIgnoreCase("Denmark")) {
  51. if (stock.equalsIgnoreCase("flags")) {
  52. sum = 3.10;
  53. } else if (stock.equalsIgnoreCase("caps")) {
  54. sum = 6.50;
  55. } else if (stock.equalsIgnoreCase("posters")) {
  56. sum = 4.80;
  57. } else if (stock.equalsIgnoreCase("stickers")) {
  58. sum = 0.90;
  59. }
  60. } else {
  61. System.out.println("Invalid country!");
  62. return;
  63. }
  64. totalPrice = sum * quantity;
  65.  
  66. System.out.printf("Pepi bought %.0f %s of %s for %.2f lv.", quantity, stock, country, totalPrice);
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment