Advertisement
Guest User

04. CSGO

a guest
Mar 12th, 2018
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.         int numObjects = Integer.valueOf(sc.nextLine());
  10.         int money = Integer.valueOf(sc.nextLine());
  11.         int ak47 = 0;
  12.         int awp = 0;
  13.         int sg553 = 0;
  14.         int grenade = 0;
  15.         int flash = 0;
  16.         int glock = 0;
  17.         int bazooka = 0;
  18.  
  19.         if (numObjects > 7) {
  20.             System.out.println("Sorry, you can't carry so many things!");
  21.         } else {
  22.             for (int i = 1; i <= numObjects; i++) {
  23.                 String arms = sc.nextLine();
  24.                 if (arms.equals("ak47")) {
  25.                     ak47++;
  26.                 }
  27.                 if (arms.equals("awp")) {
  28.                     awp++;
  29.                 }
  30.                 if (arms.equals("sg553")) {
  31.                     sg553++;
  32.                 }
  33.                 if (arms.equals("grenade")) {
  34.                     grenade++;
  35.                 }
  36.                 if (arms.equals("flash")) {
  37.                     flash++;
  38.                 }
  39.                 if (arms.equals("glock")) {
  40.                     glock++;
  41.                 }
  42.                 if (arms.equals("bazooka")) {
  43.                     bazooka++;
  44.                 }
  45.  
  46.             } int sumBazooka = 5600*bazooka;
  47.               int sumGlock = 500*glock;
  48.               int sumFlash = 250*flash;
  49.               int sumGrenade = 300*grenade;
  50.               int sumSg553 = 3500*sg553;
  51.               int sumAwp = 4750*awp;
  52.               int sumAk47 = 2700*ak47;
  53.               int sumArms = sumBazooka+sumGlock+sumFlash+sumGrenade+sumSg553+sumAwp+sumAk47;
  54.               if (sumArms>money){
  55.                   int difMoney = sumArms-money;
  56.                   System.out.println("Not enough money! You need "+difMoney+" more money.");
  57.               } else if (sumArms<=money){
  58.                   System.out.println("You bought all "+numObjects+" items! Get to work and defeat the bomb!");
  59.               }
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement