Advertisement
Guest User

Untitled

a guest
May 23rd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TestTask10 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int numberItems = Integer.parseInt(scanner.nextLine());
  8.         int money = Integer.parseInt(scanner.nextLine());
  9.  
  10.         for (int i = 0; i < numberItems; i++) {
  11.             String type = scanner.nextLine();
  12.             if (type.equals("ak47")) {
  13.                 money -= 2700;
  14.             } else if (type.equals("awp")) {
  15.                 money -= 4750;
  16.             } else if (type.equals("sg553")) {
  17.                 money -= 3500;
  18.             } else if (type.equals("grenade")) {
  19.                 money -= 300;
  20.             } else if (type.equals("flash")) {
  21.                 money -= 250;
  22.             } else if (type.equals("glock")) {
  23.                 money -= 500;
  24.             } else if (type.equals("bazooka")) {
  25.                 money -= 5600;
  26.             }
  27.         }
  28.         if (numberItems > 7) {
  29.             System.out.println("Sorry, you can't carry so many things!");
  30.         } else if (money >= 0) {
  31.             System.out.println(" You bought all " + numberItems +
  32.                     " items! Get to work and defeat the bomb!");
  33.         } else {
  34.             System.out.println("Not enough money! You need " + Math.abs(money) + " more money.");
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement