Answer to Question #304719 in C# for kun

Question #304719

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.


1
Expert's answer
2022-03-02T08:21:08-0500
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();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS