Advertisement
Spocoman

Football Souvenirs

Sep 6th, 2024 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String country = scanner.nextLine(),
  7.                 souvenir = scanner.nextLine(),
  8.                 print = "";
  9.         int quantity = Integer.parseInt(scanner.nextLine());
  10.         double price = 0;
  11.  
  12.         switch (country) {
  13.             case "Argentina" -> {
  14.                 switch (souvenir) {
  15.                     case "flags" -> price = 3.25;
  16.                     case "caps" -> price = 7.20;
  17.                     case "posters" -> price = 5.10;
  18.                     case "stickers" -> price = 1.25;
  19.                     default -> print = "Invalid stock!";
  20.                 }
  21.             }
  22.             case "Brazil" -> {
  23.                 switch (souvenir) {
  24.                     case "flags" -> price = 4.20;
  25.                     case "caps" -> price = 8.50;
  26.                     case "posters" -> price = 5.35;
  27.                     case "stickers" -> price = 1.20;
  28.                     default -> print = "Invalid stock!";
  29.                 }
  30.             }
  31.             case "Croatia" -> {
  32.                 switch (souvenir) {
  33.                     case "flags" -> price = 2.75;
  34.                     case "caps" -> price = 6.90;
  35.                     case "posters" -> price = 4.95;
  36.                     case "stickers" -> price = 1.10;
  37.                     default -> print = "Invalid stock!";
  38.                 }
  39.             }
  40.             case "Denmark" -> {
  41.                 switch (souvenir) {
  42.                     case "flags" -> price = 3.10;
  43.                     case "caps" -> price = 6.50;
  44.                     case "posters" -> price = 4.80;
  45.                     case "stickers" -> price = 0.90;
  46.                     default -> print = "Invalid stock!";
  47.                 }
  48.             }
  49.             default -> print = "Invalid country!";
  50.         }
  51.  
  52.         if (price > 0) {
  53.             System.out.printf("Pepi bought %d %s of %s for %.2f lv.\n", quantity, souvenir, country, price * quantity);
  54.         } else {
  55.             System.out.println(print);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement