Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 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 ConsoleApp2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double money = double.Parse(Console.ReadLine());
  14.             string games = "";
  15.             int index = 0;
  16.             double spend = 0;
  17.             double sum = 0;
  18.             double tsena = 0;
  19.  
  20.             string[] masiv_igri = { "OutFall 4", "CS: OG", "Zplinter Zell", "Honored 2", "RoverWatch", "RoverWatch Origins Edition" };
  21.             double[] masiv_tseni = { 39.99, 15.99, 19.99, 59.99, 29.99, 39.99 };
  22.  
  23.             do
  24.             {
  25.                 games = Console.ReadLine();
  26.                 tsena = 0;
  27.  
  28.                 for (int i = 0; i < masiv_igri.Length; i++)
  29.                 {
  30.                     if (games == masiv_igri[i])
  31.                     {
  32.                         tsena = masiv_tseni[i];
  33.                         spend += tsena;
  34.                         index = i;
  35.                         break;
  36.                     }
  37.                 }
  38.                 if (games == "Game Time")
  39.                 {
  40.                     Console.WriteLine($"Total spent: ${spend:f2}. Remaining: ${sum:f2}");
  41.                     break;
  42.                 }
  43.                 if (tsena == 0)
  44.                 {
  45.                     Console.WriteLine("Not Found");
  46.                 }
  47.                 else if (tsena > money)
  48.                 {
  49.                     Console.WriteLine("Too Expensive");
  50.                     spend = spend - tsena;
  51.                 }
  52.                 else if (spend <= money)
  53.                 {
  54.  
  55.                     Console.WriteLine("Bought " + masiv_igri[index]);
  56.                    
  57.                 }
  58.                 if (spend >= money)
  59.                 {
  60.                     Console.WriteLine("Out of money!");
  61.                     spend -= tsena;
  62.                     break;
  63.                 }
  64.                 else
  65.                 {
  66.                     sum = money - spend;
  67.                 }
  68.                
  69.  
  70.             } while (games != "Game Time");
  71.  
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement