Bank Calculator in c#

Simple bank calculator in c#

using System;

namespace ConsoleApp1
{
    class bank
    {
        public String name;
        public int id;
        public double amount;
        public double principle;
        public int time;
        public int type;
        public double interest;


        public void detail(String name, int id)
        {
            this.name = name;
            this.id = id;
        }

        public void input()
        {
            Console.WriteLine("Enter the amount of deposite");
            principle = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter the type of deposite");
            Console.WriteLine("1. Saving");
            Console.WriteLine("2. Fixed Deposite");
            type = int.Parse(Console.ReadLine());
            Console.WriteLine("Enter the time (in year): ");
            time = int.Parse(Console.ReadLine());

            if (type ==1)
            {
                interest = (principle * 6 * time) / 100;
                amount += principle + interest;
            }
            else
            {
                amount = (principle * 7.5 * time) / 100;
                amount += principle + interest;
            }

            Console.WriteLine("Enter the name of Account Holder: "+name);
            Console.WriteLine("Enter Account No.: "+id);
            Console.WriteLine("Enter the type of deposite: "+principle);
            Console.WriteLine("type of deposite (1 for saving and 2 for fd): " + type);
            Console.WriteLine("Enter the time of priod: " + time);
            Console.WriteLine("Interest on deposite: " + interest);
            Console.WriteLine("Amount in that priod: " + amount);

        }
    }
    class b1
    {
        static void Main(string[] args)
        {
            bank us1 = new bank();
            bank us2 = new bank();
            bank us3 = new bank();
            bank us4 = new bank();

            us1.detail("Rohit",50);
            us2.detail("Lakhan",70);
            us3.detail("Ankit",90);
            us4.detail("Manish",20);

            int ch = 0;
            while(ch != 1)
            {
                Console.WriteLine("Enter the Account No.(20, 50, 70, 90)");
                int id = int.Parse(Console.ReadLine());

                switch(id)
                {
                    case 20: us4.input();
                        break;

                    case 50: us1.input();
                        break;

                    case 70: us2.input();
                        break;

                    case 90: us3.input();
                        break;
                    default:
                        Console.WriteLine("Enter the Account(20, 50, 70, 90): ");
                        break;
                }
            }
            Console.ReadKey();

        }
    }
}

One thought on “Bank Calculator in c#

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.