Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Ifstatementtest
- {
- class Program
- {
- static void Main(string[] args)
- {
- int itemPrice = 10;
- Console.Write("A man has 22 coins, how many would you like to pickpocket? : ");
- int coins = int.Parse(Console.ReadLine());
- string canPurchaseMessage = "";
- string cantPurchaseMessage = ($"You only have {coins} coins");
- if (coins > 22 || coins < 0)
- {
- Console.WriteLine("You cant pickpocket that many coins. Here are 12 coins.");
- coins = 12;
- Console.WriteLine();
- }
- if (coins >= itemPrice)
- {
- 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";
- Console.WriteLine(canPurchaseMessage);
- string userResponse = Console.ReadLine();
- if (userResponse == "1")
- {
- Console.WriteLine("You have purchased this item.");
- coins -= itemPrice;
- Console.WriteLine($"You now have {coins} coins.");
- }
- else if (userResponse == "2")
- {
- }
- else
- {
- Console.WriteLine("That isnt an answer.");
- }
- }
- else if (coins < itemPrice)
- {
- Console.WriteLine("This item at jimmy's shop costs {0} coins." + cantPurchaseMessage, itemPrice);
- }
- Console.WriteLine();
- Console.WriteLine("Would you like to leave the item store?");
- Console.ReadLine();
- Console.WriteLine("The system doesnt care about your response, goodbye.");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement