Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int numObjects = Integer.valueOf(sc.nextLine());
- int money = Integer.valueOf(sc.nextLine());
- int ak47 = 0;
- int awp = 0;
- int sg553 = 0;
- int grenade = 0;
- int flash = 0;
- int glock = 0;
- int bazooka = 0;
- if (numObjects > 7) {
- System.out.println("Sorry, you can't carry so many things!");
- } else {
- for (int i = 1; i <= numObjects; i++) {
- String arms = sc.nextLine();
- if (arms.equals("ak47")) {
- ak47++;
- }
- if (arms.equals("awp")) {
- awp++;
- }
- if (arms.equals("sg553")) {
- sg553++;
- }
- if (arms.equals("grenade")) {
- grenade++;
- }
- if (arms.equals("flash")) {
- flash++;
- }
- if (arms.equals("glock")) {
- glock++;
- }
- if (arms.equals("bazooka")) {
- bazooka++;
- }
- } int sumBazooka = 5600*bazooka;
- int sumGlock = 500*glock;
- int sumFlash = 250*flash;
- int sumGrenade = 300*grenade;
- int sumSg553 = 3500*sg553;
- int sumAwp = 4750*awp;
- int sumAk47 = 2700*ak47;
- int sumArms = sumBazooka+sumGlock+sumFlash+sumGrenade+sumSg553+sumAwp+sumAk47;
- if (sumArms>money){
- int difMoney = sumArms-money;
- System.out.println("Not enough money! You need "+difMoney+" more money.");
- } else if (sumArms<=money){
- System.out.println("You bought all "+numObjects+" items! Get to work and defeat the bomb!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement