Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 39

using System;

class Employee
{
    private string F_name;
    private String L_name;
    private double sal;

    public Employee(string f, string l, double s)


    {
    F_name=f;
    L_name=l;
    sal=s;
    }
    public String FN
    {
    set
    {
        F_name=value;
    }
    get
    {
    return F_name;
    }
    }
    public String LN
    {
    set
    {
        L_name=value;
    }
    get
    {
        return L_name;
    }
    }

    public double SL
    {
    set
    {
        if(sal<0)
        {
            sal=0;
        }
         sal=value;
    }
    get
    {
    return sal;
    }
    }
    public double ysal()
    {
    return sal*12;
    }
    public double hsal()
    {
    double h=sal+(sal*0.1);
    return h*12;
    }
    public void display()
    {
    Console.WriteLine("first name:"+FN);
    Console.WriteLine("last name:"+LN);
    Console.WriteLine("monthly salary:"+SL);
    Console.WriteLine("yearly salary:"+ysal());
    Console.WriteLine("hiked monthly salary:"+(hsal()/12));
    Console.WriteLine("yearly salary after hiked salary:"+hsal());  
    }
}
class exp1
{
    static void Main(string[] args)
    {
     Employee e1=new Employee("shrikant" ,"satpute",2000);
     Employee e2=new Employee("shreyas" ,"sakate",4000);
     Console.WriteLine("info of empoyye 1st:");
     e1.display();
     Console.WriteLine();
     Console.WriteLine("info of empoyye 2nd:");
     e2.display();
    }
}

using System;
class SavingsAccount
{
    static double AnnualInterestRate;
    private double SavingsBalance;
    private double MonthlyInterest;
   
    public double SB
    {
        set
        {
            SavingsBalance=value;
        }
        get
        {
            return SavingsBalance;
        }
    }
    public void calculateMonthlyInterest()
    {
        MonthlyInterest=SavingsBalance*(AnnualInterestRate/12);
        SavingsBalance=SavingsBalance+MonthlyInterest;
        Console.WriteLine("New Savings Balance="+SavingsBalance+" Monthly
Interest="+MonthlyInterest);
    }
    public static void modifyInterestRate(double IR)
    {
        AnnualInterestRate=IR;
    }
}

class TestSavingsAccount
{
    static void Main(string[] args)
    {
        SavingsAccount saver1=new SavingsAccount();
        SavingsAccount saver2=new SavingsAccount();
       
        saver1.SB=2000;
        saver2.SB=3000;
       
        SavingsAccount.modifyInterestRate(0.04);
       
        Console.WriteLine("For saver1:");
        saver1.calculateMonthlyInterest();
       
        Console.WriteLine("For saver2:");
        saver2.calculateMonthlyInterest();
       
        SavingsAccount.modifyInterestRate(0.05);
       
        Console.WriteLine("For saver1:");
        saver1.calculateMonthlyInterest();
       
        Console.WriteLine("For saver2:");
        saver2.calculateMonthlyInterest();
    }
}

using System;
abstract class Shape
{
    public double area,perimeter,side;
    public abstract void CalculateArea();
    public abstract void CalculatePerimeter();
   
    public void display()
    {
    Console.WriteLine("side:"+side);
    Console.WriteLine("area:"+area);
    Console.WriteLine("perimeter:"+perimeter);
    }
}
    class Triangle:Shape
{
    double b,h;
     
    public Triangle(double b,double h,double side)
    {
        this.side=side;
        this.h=h;
        this.b=b;
    }
    override public void CalculateArea()
    {
        area=b*h*0.5;
    }
    override public void CalculatePerimeter()
    {
        perimeter= b+h+side;
    }
    public void show()
    {
        Console.WriteLine("base="+b);
        Console.WriteLine("height="+h);
        CalculatePerimeter();
        CalculateArea();
        display();}
    }
class Rectangle:Shape
{
    double b ;
    public Rectangle(double l,double b)
    {
        this.side=l;
        this.b=b;
    }
    override public void CalculateArea()
    {
     area= side*b;
    }
     override public void CalculatePerimeter()
    {
        perimeter= 2*(side+b);
    }
    public void show()
    {
       
        Console.WriteLine("bredth="+b);
        CalculatePerimeter();
        CalculateArea();
        display();
   
    }
}
 class Circle:Shape
{
   
    public Circle(double r)
    {
        this.side=r;
       
    }
    override public void CalculateArea()
    {
     area=3.14*side*side;
     }
     override public void CalculatePerimeter()
     {
        perimeter=2*3.14*side;
    }
    public void show()
    {  
        CalculatePerimeter();
        CalculateArea();
        display();
    }
}
    class Square:Shape
{
   
    public Square(double s)
    {
    side=s;    
    }
    override public void CalculateArea()
    {
    area=side*side;
    }
    override public void CalculatePerimeter()
    {
         perimeter=side*4;
    }
    public void show()
    {
        CalculatePerimeter();
        CalculateArea();
        display();
    }
}
    class Cube:Shape
{
   
    public Cube(double s)
    {
        side=s;
       
    }
    override public void CalculateArea()
    {
        area=6*side*side;
    }
    override public void CalculatePerimeter()
    {
         perimeter=side*12;
    }
    public void show()
    {
        CalculatePerimeter();
        CalculateArea();
        display();
    }
}
public class Exp3
{
    public static void Main(string[] args)
    {
    Triangle t=new Triangle(6,8,9);
    Circle c=new Circle(6);
    Rectangle r=new Rectangle(7,9);
    Square s=new Square(9);
    Cube c1=new Cube(8);
    Console.WriteLine("TRIANGLE INFO:");
    t.show();
    Console.WriteLine("RECTANGLE INFO:");
    r.show();
    Console.WriteLine("CIRCLE INFO:");
    c.show();
    Console.WriteLine("SQUARE INFO:");
    s.show();
    Console.WriteLine("CUBE INFO:");
    c1.show();
}
}

using System;
interface stack
{
   
    void push(string s);
   String pop();
   void display();
   bool overflow();
  bool undeflow();
}
class IntegerStack : stack
{
    static int size=5;
    int[] a=new int[size];
    int top=-1;
    public void push(string p)
    {
       
        int s;
        s=Int32.Parse(p);
        if(overflow())
        {
            Console.WriteLine("overflow");
        }
        else{
        top++;
        a[top]=s;}
     }
    public  string pop()
    {
        if(undeflow())
        {
            return "underflow";
        }
        else{
         int m;
        m=a[top];
        string n=m.ToString();
        top--;
        return n;}
    }
    public void display()
    {
        for(int i=0;i<=top;i++)
        {
            Console.WriteLine(a[i]);
        }
    }
    public bool undeflow()
    {
        if(top==-1)
        {
            return true;
        }
        else
            return false;
    }
    public bool overflow()
    {
        if(top==size-1)
        {
            return true;
        }
        else
            return false;
    }
}
class StringStack : stack
{
    static int size=5;
    string[] a=new string[size];
    int top=-1;
    public void push(string p)
    {
        if(overflow())
        {
            Console.WriteLine("overflow");
        }
        else{
       
        top++;
        a[top]=p;}
    }
    public String pop()
    {
        if(undeflow())
        {
            return "underflow";
        }
        else{
       
        String p;
        p=a[top];
        top--;
        return p;}
    }
    public void display()
    {
        for(int i=0;i<=top;i++)
        {
            Console.WriteLine(a[i]);
        }
    }
    public bool undeflow()
    {
        if(top==-1)
        {
            return true;
        }
        else
            return false;
    }
    public bool overflow()
    {
        if(top==size-1)
        {
            return true;
        }
        else
            return false;
    }
}
class DoubleStack : stack
{
    static int size=5;
    double[] a=new double[size];
    int top=-1;
    public void push(string p)
    {
      double s;
        s=Double.Parse(p);
        if(overflow())
        {
            Console.WriteLine("overflow");
        }
        else
        {
            top++;
            a[top]=s;
        }  
     }
    public  string pop()
    {
        if(undeflow())
        {
            return "underflow";
        }
        else{
         double m;
        m=a[top];
        string n=m.ToString();
        top--;
        return n;}
    }
    public void display()
    {
        for(int i=0;i<=top;i++)
        {
            Console.WriteLine(a[i]);
        }
    }
    public bool undeflow()
    {
        if(top==-1)
        {
            return true;
        }
        else
            return false;
    }
    public bool overflow()
    {
        if(top==size-1)
        {
            return true;
        }
        else
            return false;
    }

}
public class exp4
{
    public static void Main(string [] args)
    {
        int choice;

        do
        {
            Console.WriteLine("choice 1 for Stringstack");
            Console.WriteLine("choice 2 for Integerstack");
            Console.WriteLine("choice 3 for Doublestack");
            Console.WriteLine("choice 4 for exit");
            Console.WriteLine("enter your choice");
             //Scanner n4=new Scanner(System.in);
             string ch=Console.ReadLine();
             choice=Convert.ToInt32(ch);
            switch (choice)
            {
            case 1:
                {
                StringStack obj1=new StringStack();
                 int choice2;
                do
                {
                    Console.WriteLine("choice 1 for pushed string into
stringstack");
                     Console.WriteLine("choice 2 for poped string from
stringstack");
                    Console.WriteLine("choice 3 for display stringstack");
                    Console.WriteLine("choice 4 for exit");
                    // Scanner n5=new Scanner(System.in);
                    Console.WriteLine("enter your choice2");
                    string ch2=Console.ReadLine();
                      choice2=Convert.ToInt32(ch);
                    //choice2=Console.ReadLine();
                    switch (choice2)
                    {
                    case 1:
                    {      Console.WriteLine("enter a string which you want to
push in to stringstack");                            
                           
                            string  a=Console.ReadLine();
                            obj1.push(a);
                            Console.WriteLine("pushed string:"+a);
                            break;
                    }
                    case 2:
                    {
                        string m=obj1.pop();
                        Console.WriteLine("poped String:"+m);
                        break;
                    }
                    case 3:
                    {
                        Console.WriteLine("elements in an string stack:");
                        obj1.display();
                        break;
                    }
                    case 4:
                    {
                    break;
                    }
                    default:
                    {
                        Console.WriteLine("unvalid choice");
                        break;
                    }
                    }
                }
                while(choice2!=4);
                break;
            }

            case 2:
            {
                IntegerStack obj1=new IntegerStack();
                int choice2;
                do
                {
                    Console.WriteLine("choice 1 for pushed element into
Integerstack");
                     Console.WriteLine("choice 2 for poped string from
Integerstack");
                    Console.WriteLine("choice 3 for display Integerstack");
                    Console.WriteLine("choice 4 for exit");
                     //Scanner n6=new Scanner(System.in);
                   
                    Console.WriteLine("enter a choice2");
                   
                    string ch3=Console.ReadLine();
                    choice2=Convert.ToInt32(ch3);
                    switch (choice2)
                    {
                    case 1:
                    {
                        //Scanner s=new Scanner(System.in);
                        Console.WriteLine("enter a string which you want to
push in to integer stack");
                       
                        string a=Console.ReadLine();
                        obj1.push(a);
                        Console.WriteLine("pushed integer elment:"+a);
                        break;
                    }
                    case 2:
                    {
                        string m=obj1.pop();
                        Console.WriteLine("poped integer element:"+m);
                        break;
                    }
                    case 3:
                    {
                        Console.WriteLine("elements in an Integer stack:");
                        obj1.display();
                        break;
                    }
                    case 4:
                    {
                    break;
                    }
                    default:
                    {
                        Console.WriteLine("unvalid choice");
                        break;
                   
                    }
                   
                    }
                }
                while(choice2!=4);
                break;
            }

            case 3:
            {
                DoubleStack obj1=new DoubleStack();
                int choice2;
                do
                {
                    Console.WriteLine("choice 1 for pushed element into
Doublestack");
                    Console.WriteLine("choice 2 for poped element from
Doublestack");
                    Console.WriteLine("choice 3 for display Doublestack");
                    Console.WriteLine("choice 4 for exit");
                    Console.WriteLine("enter your choice2");
                   
                    string ch4=Console.ReadLine();
                    choice2=Convert.ToInt32(ch4);
                   
                    switch (choice2)
                    {
                    case 1:
                    {
                        //Scanner n2=new Scanner(System.in);
                        Console.WriteLine("enter a element which you want to
push in to double stack");
                       string a=Console.ReadLine();
                        obj1.push(a);
                        Console.WriteLine("pushed double element:"+a);
                        break;
                    }
                    case 2:
                    {
                        string m=obj1.pop();
                        Console.WriteLine("poped double elment:"+m);
                        break;
                    }
                    case 3:
                    {
                        Console.WriteLine("elements in an string stack:");
                        obj1.display();
                        break;
                    }
                    case 4:
                    {
                    break;
                    }
                    default:
                    {
                        Console.WriteLine("unvalid choice");
                        break;
                   
                    }
                    }}
                while(choice2!=4);
                break;
            }
            case 4:
                    {
                    break;
                    }
                    default:
                    {
                        Console.WriteLine("unvalid choice");
                        break;
                    }
            }  
            }
            while(choice!=4);
    }
}

       

using System;
public class expp6
{
    public  void divide() //throws ArithmeticException
    {
        int a;
        int b;
       // Scanner s=new Scanner(System.in);
        Console.WriteLine("enter value for a");
        a=Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("enter value for b");
        b=Convert.ToInt32(Console.ReadLine());
        try
        {
            int c= a/b;
            Console.WriteLine("result:"+c);
            Console.WriteLine("exception not occure");
        }
        catch(Exception e)
        {
            Console.WriteLine("divisor cant be zero");
            Console.WriteLine(e);
        }
        finally {
            Console.WriteLine("this is end of divide function");
        }

    }
    public void number()// throws InputMismatchException
    {
        int x;
        Console.WriteLine("enter a input for x:");
       // Scanner sc=new Scanner(System.in);
        try
        {
            x=Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("x="+x);
            Console.WriteLine("exception not occure");

        }
        catch(Exception e)
        {
            Console.WriteLine("variable 'a' have integer type so give input as
integer");
            Console.WriteLine(e);
        }
        finally {
            Console.WriteLine("this is end of function");
        }

    }
    public void arraylength() //throws ArrayIndexOutOfBoundsException
    {
        //Scanner sc=new Scanner(System.in);
        Console.WriteLine("enter the size of an array");
        int n=Convert.ToInt32(Console.ReadLine());
        int []x=new int[n];
        Console.WriteLine("enter a index of an array which u have to pass
element");
        int m=Convert.ToInt32(Console.ReadLine());
        try
        {
            x[m]=90;
            Console.WriteLine("x["+m+"]="+x[m]+"\n");
            Console.WriteLine("exception not occure");
        }
        catch(Exception e)
        {
            Console.WriteLine("array index out of size");
            Console.WriteLine(e);
        }
        finally {
            Console.WriteLine("this is end of  function");
        }

    }
    public void nullPointer()//throws NullPointerException
    {
        try
        {
            expp6 obj=null;
            obj.divide();
        }
        catch(Exception e)
        {
            Console.WriteLine("Cannot invoke any function by obj which having
only reference");
            Console.WriteLine(e);
        }
        finally {
            Console.WriteLine("this is end of  function");
        }

    }
    public void conversion()//throws NumberFormatException
    {
       // Scanner sc=new Scanner(System.in);
        Console.WriteLine("enter a string which u want to convert into
integer");
        String n=Console.ReadLine();
        try
        {

            int m=Int32.Parse(n);
            Console.WriteLine("integer form of "+n+":"+m);
            Console.WriteLine("exception not occure");
        }
        catch(Exception e)
        {
            //Console.WriteLine("Cannot invoke divide function");
            Console.WriteLine(e);
        }
        finally {
            Console.WriteLine("this is end of  function");
        }
    }
    public static void Main(string[] args)
    {
        expp6 obj=new expp6();
        obj.divide();
        obj.number();
        obj.arraylength();
        obj.conversion();
        obj.nullPointer();
    }
}

//import java.util.*;
using System;
class LowBalanceException : Exception
{
    public LowBalanceException()
    {
        //super();
        Console.WriteLine( "sorry you have low balance");
    }
}
class NegativeNumberException : Exception
{
   
    public NegativeNumberException()
    {
        //super();
        Console.WriteLine("amount cant be negative");
    }
}
class PasswordMissmatchException : Exception
{
   
    public PasswordMissmatchException()
    {
        //super();
        Console.WriteLine("password is wrong please check it");
}
}
class BankAccount
{
    private double amount;
    private string password;
    private string name;
    private int ANO;
    public void set_amount(double amount)
    {

        this.amount=amount;
    }
    public void set_name(string name)
    {

        this.name=name;
    }
    public void set_ANO(int ANO)
    {
        this.ANO=ANO;
    }
    public void set_password(string password)
    {
        this.password=password;
    }
    public BankAccount(string nm,int AN,double amt)
    {
        set_amount(amt);
        set_name(nm);
        set_ANO(AN);
    }
    public void blanceEnquiery()
    {
        Console.WriteLine("****BALANCE ENQUIREY****");
        string pass;
        Console.WriteLine("enter your password");
//Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("your current balance is:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void withdraw()
    {
        Console.WriteLine("****WITHDRAW****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to withdraw
from your account:");
                amt=Convert.ToDouble(Console.ReadLine());
;
                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount-amt;
                        Console.WriteLine("you have withdraw amount rupees
"+amt);
                    }
                }

                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);
                    //e.ToString();
                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                    e.ToString();
                }
            }

        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void deposite()
    {
        Console.WriteLine("****DEPOSITE****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to deposite
your account:");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount+amt;
                        Console.WriteLine("you have deposite amount rupees
"+amt);
                    }
                }

                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                }
            }

        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void transfer(BankAccount b1)
    {
        Console.WriteLine("****TRANSFER****");
       // BankAccount b1=new BankAccount("mrunal",101,90000);

        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
    pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to transfer to
other account");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    else if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {

                        b1.amount=b1.amount+amt;
                        amount=amount-amt;
                        Console.WriteLine("amount transfer to b1
account"+amt);
                        Console.WriteLine("Sender account info:");
                        display();
                        Console.WriteLine("Reciver account info:");
                        b1.display();

                    }
                }

                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);

                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);

                }
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void display()
    {
        Console.WriteLine("****Display****");
        string pass;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("NAME:"+name);
                Console.WriteLine("ACOOUNT NO:"+ANO);
                Console.WriteLine("BALANCE:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
}

public class expp7


{
    public static void Main(string[] args) //throws
PasswordMissmatchException,LowBalanceException,NegativeNumberException
    {
      BankAccount[] obj=new BankAccount[2];  
       obj[0]=new BankAccount("Akshata",100,9000);
       obj[1]=new BankAccount("mrunal" ,101,10000);
      // BankAccount obj=new BankAccount("Akshata",100,9000);
        obj[0].set_password("akshata16");
        obj[1].set_password("mrunal");
        int choice;
        //while(choice!=5)
        do
        {
            Console.WriteLine("choice 1:blanceEnquiery");
            Console.WriteLine("choice 2:Withdraw");
            Console.WriteLine("choice 3:Deposite");
            Console.WriteLine("choice 4:Transfer");
            Console.WriteLine("choice 5:display");
            Console.WriteLine("choice 6:exit");
           // Scanner s=new Scanner(System.in);
            Console.WriteLine("enter choice:");
            choice=Convert.ToInt32(Console.ReadLine());

            switch(choice)
            {
            case 1:
                obj[0].blanceEnquiery();
                break;
            case 2:
                obj[0].withdraw();
                break;
            case 3:
                obj[0].deposite();
                break;
            case 4:
                obj[0].transfer(obj[1]);
                break;
            case 5:
                obj[0].display();
                break;
            case 6:
                break;
            default:
                Console.WriteLine("invalid choice");
                break;
            }
        }
        while(choice!=6);

    }
}

//import java.util.*;
using System;
class LowBalanceException : Exception
{
    public LowBalanceException()
    {
        //super();
        Console.WriteLine( "sorry you have low balance");
    }
}
class NegativeNumberException : Exception
{
   
    public NegativeNumberException()
    {
        //super();
        Console.WriteLine("amount cant be negative");
    }
}
class PasswordMissmatchException : Exception
{
   
    public PasswordMissmatchException()
    {
        //super();
        Console.WriteLine("password is wrong please check it");
}
}
class BankAccount
{
    private double amount;
    private string password;
    private string name;
    private int ANO;
    public void set_amount(double amount)
    {

        this.amount=amount;
    }
    public void set_name(string name)
    {

        this.name=name;
    }
    public void set_ANO(int ANO)
    {
        this.ANO=ANO;
    }
    public void set_password(string password)
    {
        this.password=password;
    }
    public BankAccount(string nm,int AN,double amt)
    {
        set_amount(amt);
        set_name(nm);
        set_ANO(AN);
    }
    public void blanceEnquiery()
    {
        Console.WriteLine("****BALANCE ENQUIREY****");
        string pass;
        Console.WriteLine("enter your password");
//Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("your current balance is:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void withdraw()
    {
        Console.WriteLine("****WITHDRAW****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to withdraw
from your account:");
                amt=Convert.ToDouble(Console.ReadLine());
;
                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount-amt;
                        Console.WriteLine("you have withdraw amount rupees
"+amt);
                    }
                }

                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);
                    //e.ToString();
                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                    e.ToString();
                }
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void deposite()
    {
        Console.WriteLine("****DEPOSITE****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to deposite
your account:");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount+amt;
                        Console.WriteLine("you have deposite amount rupees
"+amt);
                    }
                }

                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                }
            }

        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void transfer(BankAccount b1)
    {
        Console.WriteLine("****TRANSFER****");
       // BankAccount b1=new BankAccount("mrunal",101,90000);

        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
    pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to transfer to
other account");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    else if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {

                        b1.amount=b1.amount+amt;
                        amount=amount-amt;
                        Console.WriteLine("amount transfer to b1
account"+amt);
                        Console.WriteLine("Sender account info:");
                        display();
                        Console.WriteLine("Reciver account info:");
                        b1.display();
                    }
                }

                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);

                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);

                }
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void display()
    {
        Console.WriteLine("****Display****");
        string pass;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("NAME:"+name);
                Console.WriteLine("ACOOUNT NO:"+ANO);
                Console.WriteLine("BALANCE:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }

    }
}
public class expp7
{
    public static void Main(string[] args) //throws
PasswordMissmatchException,LowBalanceException,NegativeNumberException
    {
      BankAccount[] obj=new BankAccount[2];  
       obj[0]=new BankAccount("Akshata",100,9000);
       obj[1]=new BankAccount("mrunal" ,101,10000);
      // BankAccount obj=new BankAccount("Akshata",100,9000);
        obj[0].set_password("akshata16");
        obj[1].set_password("mrunal");
        int choice;
        //while(choice!=5)
        do
        {
            Console.WriteLine("choice 1:blanceEnquiery");
            Console.WriteLine("choice 2:Withdraw");
            Console.WriteLine("choice 3:Deposite");
            Console.WriteLine("choice 4:Transfer");
            Console.WriteLine("choice 5:display");
            Console.WriteLine("choice 6:exit");
           // Scanner s=new Scanner(System.in);
            Console.WriteLine("enter choice:");
            choice=Convert.ToInt32(Console.ReadLine());

            switch(choice)
            {
            case 1:
                obj[0].blanceEnquiery();
                break;
            case 2:
                obj[0].withdraw();
                break;
            case 3:
                obj[0].deposite();
                break;
            case 4:
                obj[0].transfer(obj[1]);
                break;
            case 5:
                obj[0].display();
                break;
            case 6:
                break;
            default:
                Console.WriteLine("invalid choice");
                break;
            }
        }
        while(choice!=6);

    }
}

//import java.util.*;
using System;
class LowBalanceException : Exception
{
    public LowBalanceException()
    {
        //super();
        Console.WriteLine( "sorry you have low balance");
    }
}
class NegativeNumberException : Exception
{
   
    public NegativeNumberException()
    {
        //super();
        Console.WriteLine("amount cant be negative");
    }
}
class PasswordMissmatchException : Exception
{
   
    public PasswordMissmatchException()
    {
        //super();
        Console.WriteLine("password is wrong please check it");
}
}
class BankAccount
{
    private double amount;
    private string password;
    private string name;
    private int ANO;
    public void set_amount(double amount)
    {

        this.amount=amount;
    }
    public void set_name(string name)
    {

        this.name=name;
    }
    public void set_ANO(int ANO)
    {
        this.ANO=ANO;
    }
    public void set_password(string password)
    {
        this.password=password;
    }
    public BankAccount(string nm,int AN,double amt)
    {
        set_amount(amt);
        set_name(nm);
        set_ANO(AN);
    }
    public void blanceEnquiery()
    {
        Console.WriteLine("****BALANCE ENQUIREY****");
        string pass;
        Console.WriteLine("enter your password");
//Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("your current balance is:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void withdraw()
    {
        Console.WriteLine("****WITHDRAW****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to withdraw
from your account:");
                amt=Convert.ToDouble(Console.ReadLine());
;
                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount-amt;
                        Console.WriteLine("you have withdraw amount rupees
"+amt);
                    }
                }

                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);
                    //e.ToString();
                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                    e.ToString();
                }
            }

        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void deposite()
    {
        Console.WriteLine("****DEPOSITE****");
        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to deposite
your account:");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {
                        amount=amount+amt;
                        Console.WriteLine("you have deposite amount rupees
"+amt);
                    }
                }

                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);
                }
            }

        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void transfer(BankAccount b1)
    {
        Console.WriteLine("****TRANSFER****");
       // BankAccount b1=new BankAccount("mrunal",101,90000);

        string pass;
        double amt;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
    pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("enter amount which you want to transfer to
other account");
                amt=Convert.ToDouble(Console.ReadLine());

                try
                {
                    if(amount<amt)
                    {
                        throw new LowBalanceException();
                    }
                    else if(amt<0)
                    {
                        throw new NegativeNumberException();
                    }
                    else
                    {

                        b1.amount=b1.amount+amt;
                        amount=amount-amt;
                        Console.WriteLine("amount transfer to b1
account"+amt);
                        Console.WriteLine("Sender account info:");
                        display();
                        Console.WriteLine("Reciver account info:");
                        b1.display();

                    }
                }
                catch( LowBalanceException e)
                {
                    Console.WriteLine(e);

                }
                catch( NegativeNumberException e)
                {
                    Console.WriteLine(e);

                }
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }
    }
    public void display()
    {
        Console.WriteLine("****Display****");
        string pass;
        Console.WriteLine("enter your password");
       // Scanner s=new Scanner(System.in);
        pass=Console.ReadLine();
        try
        {
            if(!pass.Equals(password))
            {
                throw new PasswordMissmatchException();
            }
            else
            {
                Console.WriteLine("NAME:"+name);
                Console.WriteLine("ACOOUNT NO:"+ANO);
                Console.WriteLine("BALANCE:"+amount);
            }
        }
        catch(PasswordMissmatchException e)
        {
            Console.WriteLine(e);
        }

    }
}

public class expp7


{
    public static void Main(string[] args) //throws
PasswordMissmatchException,LowBalanceException,NegativeNumberException
    {
      BankAccount[] obj=new BankAccount[2];  
       obj[0]=new BankAccount("Akshata",100,9000);
       obj[1]=new BankAccount("mrunal" ,101,10000);
      // BankAccount obj=new BankAccount("Akshata",100,9000);
        obj[0].set_password("akshata16");
        obj[1].set_password("mrunal");
        int choice;
        //while(choice!=5)
        do
        {
            Console.WriteLine("choice 1:blanceEnquiery");
            Console.WriteLine("choice 2:Withdraw");
            Console.WriteLine("choice 3:Deposite");
            Console.WriteLine("choice 4:Transfer");
            Console.WriteLine("choice 5:display");
            Console.WriteLine("choice 6:exit");
           // Scanner s=new Scanner(System.in);
            Console.WriteLine("enter choice:");
            choice=Convert.ToInt32(Console.ReadLine());

            switch(choice)
            {
            case 1:
                obj[0].blanceEnquiery();
                break;
            case 2:
                obj[0].withdraw();
                break;
            case 3:
                obj[0].deposite();
                break;
            case 4:
                obj[0].transfer(obj[1]);
                break;
            case 5:
                obj[0].display();
                break;
            case 6:
                break;
            default:
                Console.WriteLine("invalid choice");
                break;
            }
        }
        while(choice!=6);
    }
}

using System;
using System.Net;

class Program {
   static void Main(){
   try{
      String hostName = string.Empty;
      hostName = Dns.GetHostName();
      Console.WriteLine("Hostname: "+hostName);
      IPHostEntry myIP = Dns.GetHostEntry(hostName);

      IPAddress[] address = myIP.AddressList;

      for (int i = 1; i < address.Length; i++) {


         Console.WriteLine("IP Address {1} : ",address[i].ToString());
      }
      Console.ReadLine();
   }catch(Exception e)
   {
      Console.WriteLine(e);
   }
     Console.ReadKey();
   }
}

You might also like