Sunday, 9 September 2012

1.LOOPING & BRANCHING


LOOPING & BRANCHING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace banking
{ 
  class Program
    {  
     static void Main(string[] args)
        {
            int accno,tot=500,wth,dep,bal,ch;
            Console.WriteLine(" ");
            Console.WriteLine("***************Welcome***************");
            Console.WriteLine("Enter Account number");
            accno = int.Parse(Console.ReadLine());
            while (true)
            {
                Console.WriteLine("1.Deposit");
                Console.WriteLine("2.Withdraw");
                Console.WriteLine("3.Balance Enquiry");
                Console.WriteLine("4.Exit");
                Console.WriteLine("Enter ur Choice");
                ch = int.Parse(Console.ReadLine());
                switch (ch)
                {
                    case 1:
                        Console.WriteLine("Enter Deposit Amount");
                        dep = int.Parse(Console.ReadLine());
                        tot = tot + dep;
                        break;
                    case 2:
                        Console.WriteLine("Enter Amount to Withdraw");
                        wth = int.Parse(Console.ReadLine());
                        if (tot <= 500)
                            Console.WriteLine("Low Balance");
                        else
                        {
                            tot = tot - wth;
                            Console.WriteLine("transaction Succesfull");
                        }
                        break;
                    case 3:
                        Console.WriteLine("Current balance " + tot);
                        break;
                    case 4:
                        break;
                }
            }
        }
    }
}

No comments:

Post a Comment