Giter Site home page Giter Site logo

yogabharathi3 / 19ai308-object-oriented-programming-using-csharp-exp-9---interface-with-abstract-methods Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aswini-j/19ai308-object-oriented-programming-using-csharp-exp-9---interface-with-abstract-methods

0.0 0.0 0.0 5 KB

19ai308-object-oriented-programming-using-csharp-exp-9---interface-with-abstract-methods's Introduction

19AI308-Object-Oriented-Programming-using-CSharp-Exp-9---Interface-with-abstract-methods

AIM:

To develop a small bank application by declaring deposit() and withdrawal() as an abstract methods in the interface.

ALGORITHM:

STEP 1.

Interface Bank: defines deposit and withdraw methods.

STEP 2.

Program class: implements Bank, manages deposit and withdrawal operations.

STEP 3.

Constructor: prompts user for deposit or withdrawal choice.

STEP 4.

deposit method: adds entered amount to balance, displays updated balance.

STEP 5.

withdraw method: subtracts entered amount from balance, displays updated balance.

STEP 6.

Main method: creates Program object, initiates banking operations based on user input.

PROGRAM:

Developed by:Yogabharathi S Register number:212222230179

using System;
using System.Transactions;
public interface Bank
{
    void deposit();
    void withdraw();
}
public class Program:Bank
{
    public int amount,balance=5000;
    public Program()
    {
        Console.WriteLine("Enter your Choice:\n1.Deposit\n2.WithDraw");
        int opt;
        opt = Convert.ToInt32(Console.ReadLine());
        if (opt == 1)
            deposit();
        else if (opt == 2)
            withdraw();
        else
        {
            Console.WriteLine("Enter a valid input");
        }
    }
    public void deposit()
    {
        Console.WriteLine("Enter the amount to deposit");
        amount = Convert.ToInt32(Console.ReadLine());
        balance += amount;
        Console.WriteLine("The Balance is " + balance);
    }
    public void withdraw()
    {
        Console.WriteLine("Enter the amount to withdraw");
        amount = Convert.ToInt32(Console.ReadLine());
        balance -= amount;
        Console.WriteLine("The Balance is " + balance);
    }
}
public class Exp9
{
    public static void Main(string[] args)
    {
        Program n = new Program();
    }
}

OUTPUT:

image

RESULT:

Thus, a C# program has created for developing a small bank application by declaring deposit() and withdraw() as an abstract methods in the interface and it is executed and verified successfully.

19ai308-object-oriented-programming-using-csharp-exp-9---interface-with-abstract-methods's People

Contributors

aswini-j avatar yogabharathi3 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.