Friday, 28 October 2016

ISC Computer 2016 Theory Part II : Section C Fully Solved

Section C : 2016 Solved Theory


Question :10

Inheritance From Account to Bank 

public class Bank
{
    String name;
    long accno;
    double p;
    Bank(String n,long a,double s)
    {
        name=n;
        accno=a;
        p=s;
    }
    void display()
    {
        System.out.println("Customer's Name : "+name);
        System.out.println("Customer's Account Number : "+accno);
        System.out.println("Customer's Principal Ammount : "+p);
    }
}


public class Account extends Bank
{
    double amt;
    Account(double a,String na,long no,double sm)
    {
        super(na,no,sm);
        amt=a;
    }
    void deposit()
    {
        p=p+amt;
    }
    void withdraw()
    {
        if(p>=amt)
        {
            p=p-amt;
            if(p<500)
            {
                p=p-(500-p)/10;
            }
        }
        else
        {
            System.out.println("INSUFFICIENT BALANCE");
        }
    }
    void display()
    {
        System.out.println("Customer's Name : "+name);
        System.out.println("Customer's Account Number : "+accno);
        System.out.println("Customer's Principal Ammount : "+p);
    }
}


Question :11

Stack programming using LIFO : Book Shelf 

public class Book
{
    String name[]=new String[100];
    int point,max;
    Book(int cap)
    {
        max=cap;
        point=-1;
    }
    void tell()
    {
        if(point==-1)
        {
            System.out.println("SHELF EMPTY");
        }
        else
        {
            System.out.println(name[point]+" is last book entered at "+(point+1)+".");
        }
    }
    void add(String v)
    {
        if((point+1)==max)
        {
            System.out.println("SHELF FULL");
        }
        else
        {
            name[++point]=v;
        }
    }
    void display()
    {
        int i;
        System.out.println("POSITION\t\tNAME OF THE BOOKS");
        System.out.println("--------------------------------------------------------------------");
        for(i=0;i<=point;i++)
        {
            System.out.println((i+1)+".\t\t\t"+name[i]);
        }
    }
}
   

1 comment: