Write a program that prompts the user his balance as well as an amount to be withdrawn from his/her bank account. Display an error message if the amount is more than the balance; otherwise display the new balance.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter you balance: ");
decimal balance = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("Please enter withdraw amount: ");
decimal amount = Convert.ToDecimal(Console.ReadLine());
if (amount > balance)
{
Console.WriteLine("The amount is more than the balance!");
}
else
{
Console.WriteLine("Your balance: {0}", balance - amount);
}
Console.ReadKey();
}
}
}
Comments
Leave a comment