Advertisement
Aliendreamer

heists array more excercises

Jun 20th, 2018
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _11.MORE._6.Heist
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //first line
  14.             string[] input = Console.ReadLine().Split(' ');
  15.             int jewelPrice = int.Parse(input[0]); //10
  16.             int goldPrice = int.Parse(input[1]); //20
  17.  
  18.            
  19.             string commands;                                  
  20.        
  21.             long totalExpenses = 0;
  22.        
  23.             long totalMoney = 0;
  24.  
  25.  
  26.             while ((commands = Console.ReadLine())!= "Jail Time") // DaS@!%$$ 40
  27.             {
  28.                 int jewelsQuantity = 0;
  29.                 int goldQuantity = 0;
  30.                
  31.                
  32.                 string[] commandArgs = commands.Split(' ');
  33.                 string loot = commandArgs[0];
  34.                 long expenses = long.Parse(commandArgs[1]);
  35.  
  36.                 for (int i = 0; i < loot.Length; i++)
  37.                 {
  38.                     if (loot[i] == '%')
  39.                     {
  40.                         jewelsQuantity++;
  41.                     }
  42.                     else if (loot[i] =='$')
  43.                     {
  44.                         goldQuantity++;
  45.                     }
  46.  
  47.                 }
  48.                 totalExpenses += expenses;
  49.  
  50.  
  51.                 long totalJewel = jewelPrice * jewelsQuantity;
  52.  
  53.                 long totalGold =  goldPrice * goldQuantity;
  54.                
  55.                 long totalHeistAmount=totalJewel+totalGold;
  56.  
  57.                 totalMoney +=totalHeistAmount;
  58.  
  59.                
  60.             }
  61.             if (totalMoney >= totalExpenses)
  62.             {
  63.                 Console.WriteLine("Heists will continue. Total earnings: {0}.",Math.Abs(totalMoney-totalExpenses));
  64.             }
  65.             else
  66.             {
  67.                 Console.WriteLine("Have to find another job. Lost: {0}.",Math.Abs(totalMoney-totalExpenses));
  68.             }
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement