Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TestTask10 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int numberItems = Integer.parseInt(scanner.nextLine());
- int money = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < numberItems; i++) {
- String type = scanner.nextLine();
- if (type.equals("ak47")) {
- money -= 2700;
- } else if (type.equals("awp")) {
- money -= 4750;
- } else if (type.equals("sg553")) {
- money -= 3500;
- } else if (type.equals("grenade")) {
- money -= 300;
- } else if (type.equals("flash")) {
- money -= 250;
- } else if (type.equals("glock")) {
- money -= 500;
- } else if (type.equals("bazooka")) {
- money -= 5600;
- }
- }
- if (numberItems > 7) {
- System.out.println("Sorry, you can't carry so many things!");
- } else if (money >= 0) {
- System.out.println(" You bought all " + numberItems +
- " items! Get to work and defeat the bomb!");
- } else {
- System.out.println("Not enough money! You need " + Math.abs(money) + " more money.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement