Advertisement
desislava_topuzakova

04.CSGO

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