Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String country = scanner.nextLine(),
- souvenir = scanner.nextLine(),
- print = "";
- int quantity = Integer.parseInt(scanner.nextLine());
- double price = 0;
- switch (country) {
- case "Argentina" -> {
- switch (souvenir) {
- case "flags" -> price = 3.25;
- case "caps" -> price = 7.20;
- case "posters" -> price = 5.10;
- case "stickers" -> price = 1.25;
- default -> print = "Invalid stock!";
- }
- }
- case "Brazil" -> {
- switch (souvenir) {
- case "flags" -> price = 4.20;
- case "caps" -> price = 8.50;
- case "posters" -> price = 5.35;
- case "stickers" -> price = 1.20;
- default -> print = "Invalid stock!";
- }
- }
- case "Croatia" -> {
- switch (souvenir) {
- case "flags" -> price = 2.75;
- case "caps" -> price = 6.90;
- case "posters" -> price = 4.95;
- case "stickers" -> price = 1.10;
- default -> print = "Invalid stock!";
- }
- }
- case "Denmark" -> {
- switch (souvenir) {
- case "flags" -> price = 3.10;
- case "caps" -> price = 6.50;
- case "posters" -> price = 4.80;
- case "stickers" -> price = 0.90;
- default -> print = "Invalid stock!";
- }
- }
- default -> print = "Invalid country!";
- }
- if (price > 0) {
- System.out.printf("Pepi bought %d %s of %s for %.2f lv.\n", quantity, souvenir, country, price * quantity);
- } else {
- System.out.println(print);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement