Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 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 Ifstatementtest
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int itemPrice = 10;
  14.  
  15.            
  16.  
  17.             Console.Write("A man has 22 coins, how many would you like to pickpocket? : ");
  18.             int coins = int.Parse(Console.ReadLine());
  19.             string canPurchaseMessage = "";
  20.             string cantPurchaseMessage = ($"You only have {coins} coins");
  21.  
  22.             if (coins > 22 || coins < 0)
  23.             {
  24.                 Console.WriteLine("You cant pickpocket that many coins. Here are 12 coins.");
  25.                 coins = 12;
  26.                 Console.WriteLine();
  27.             }
  28.             if (coins >= itemPrice)
  29.             {
  30.                 canPurchaseMessage = "This item at jimmy's shop costs 10 coins. You can purchase this item, would you like to? Answer 1 for yes or 2 for no";
  31.                 Console.WriteLine(canPurchaseMessage);
  32.                 string userResponse = Console.ReadLine();
  33.                 if (userResponse == "1")
  34.                 {
  35.                     Console.WriteLine("You have purchased this item.");
  36.                     coins -= itemPrice;
  37.                     Console.WriteLine($"You now have {coins} coins.");
  38.                 }
  39.                 else if (userResponse == "2")
  40.                 {
  41.                 }
  42.                 else
  43.                 {
  44.                     Console.WriteLine("That isnt an answer.");
  45.                 }
  46.             }
  47.             else if (coins < itemPrice)
  48.             {
  49.                 Console.WriteLine("This item at jimmy's shop costs {0} coins." + cantPurchaseMessage, itemPrice);
  50.             }
  51.             Console.WriteLine();
  52.             Console.WriteLine("Would you like to leave the item store?");
  53.             Console.ReadLine();
  54.             Console.WriteLine("The system doesnt care about your response, goodbye.");
  55.             Console.ReadLine();
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement