Page 1 :
Monday, July 19, 2021, 8:06 PM, , COMBINED ISC 135 Page 1
Page 5 :
A superclass Product has been defined to store the, details of a product sold by a wholesaler to a retailer., Define a subclass Sales to compute the total amount, paid by the retailer with or without fine along with, service tax., Some of the members of both classes are given, below:, Class name, : Product, Data members/instance variables:, name, : stores the name of the product, code, : integer to store the product code, amount, : stores the total sale amount of, the product (in decimals), , Member functions/methods:, Product (String n, int c, double p): parameterized, constructor to assign data, members: name = n, code =c and, amount = p, void show(), : displays the details of the data, members, Class name, : Sales, Data members/instance variables:, day, : stores number of days taken to pay the, sale amount, tax, : to store the service tax (in decimals), totamt, : to store the total amount (in decimals), Member functions/methods:, Sales(….) : parameterized constructor to assign, values to data members of both the, classes., void compute() : calculates the service tax @ 12.4%, of the actual sale amount , calculates, the fine @ 2.5% of the actual sale, amount only if the amount paid by, the retailer to the wholesaler, exceeds 30 days calculates the total, amount paid by, the retailer as (actual sale amount +, service tax + fine), void show () : displays the data members of the, superclass and the total amount, , Assume that the superclass Product has been, defined. Using the concept of inheritance, specify the, class Sales giving the details of the constructor (…),, , COMBINED ISC 135 Page 5
Page 6 :
void compute() ) and void show(). The superclass,, main function and algorithm need NOT be written., , A superclass Perimeter has been defined to, calculate the perimeter of a parallelogram., Define a subclass Area to compute the area of, the parallelogram by using the required data, members of the superclass. The details are, given below:, Class name, : Perimeter, Data members/instance variables:, a, : to store the length in decimal, b, : to store the breadth in, decimal, Member functions:, Perimeter (…) : parameterized constructor to, assign values to data members, , double Calculate(): calculate and return the, perimeter of a parallelogram is, 2* (length +breadth), void show(), : to display the data members, along with the perimeter of the parallelogram, Class name, : Area, Data members/instance variables:, h, : to store the height in, decimal, area, : to store the area of the, parallelogram, Member functions:, Area(…), : parameterized constructor, to assign values to data members of both the, classes, void doarea(), : compute the area as, (breadth *height), void show(), : display the data members, of both classes along with the area and, perimeter of the parallelogram., , Specify the class Perimeter giving details of the, constructor (…), double Calculate and void, show (). Using the concept of inheritance,, specify the class Area giving details of the, constructor (…), void doarea () and void show, (). The main function and algorithm need not, be written., , COMBINED ISC 135 Page 6
Page 7 :
A superclass Number is defined to calculate the factorial of a, number. Define a subclass Series to find the sum of the series, S = 1! + 2! + 3! + 4! + ………. + n!, *5+, , The details of the members of both classes are given below:, Class name, : Number, Data member/instance variable:, n, : to store an integer number, Member functions/methods:, Number(int nn) : parameterized constructor to initialize the, data member n=nn, int factorial(int a) : returns the factorial of a number, (factorial of n = 1 × 2 × 3 × …… × n), void display(), : to print the data members., , Class name, : Series, Data member/instance variable:, sum, : to store the sum of the series, Member functions/methods:, Series(…), : parameterized constructor to initialize, the data members of both the classes, void calsum(), : calculates the sum of the given series., void display(), : displays the data members of both, the classes, Assume that the superclass Number has been defined. Using, the concept of inheritance, specify the class Series giving the, details of the constructor(…), void calsum() and void, display()., The superclass, main function and algorithm need NOT be, written., , COMBINED ISC 135 Page 7
Page 8 :
A superclass Record contains names and marks of, the students in two different single dimensional, arrays., , Define a subclass Highest to display the names of, the student obtaining the highest mark [5], The details of the members of both classes are, given below:, Class name: Record, Data member/instance variable:, n[ ], : array to store names, m[ ], : array to store marks, size, : to store the number of students, Member functions/methods:, , Record(int cap): parameterized constructor to, initialize, the data member size = cap, void readarray() : to enter elements in both the, arrays, void display() : displays the array elements, , Class name, : Highest, Data member/instance variable:, ind, : to store the index, , Member functions/methods:, Highest(…), : parameterized constructor to, initialize the data members of both the classes, void find(), , : finds the index of the student, obtaining the highest mark and, assign it to ‘ind’, , void display(), : displays the array elements, along with the names and mark of the student who, have obtained the highest mark, Assume that the superclass Record has been, defined. Using the concept of inheritance, specify, the class Highest giving the details of the, constructor(…), void find() and void display()., The superclass, main function and algorithm need, NOT be written., , A superclass Bank has been defined to store the details of a, customer. Define a sub-class Account that enables transactions, for the customer with the bank. The details of both the classes, are given below:, [5], Class name : Bank, Data members/instance variables:, name, : stores the name of the customer, accno, : stores the account number, P, : stores the principal amount in decimals, Member functions/methods:, , COMBINED ISC 135 Page 8
Page 9 :
Bank(….), , : parameterized constructor to assign values to, the instance variables, void display () : displays the details of the customer, Class name, : Account, Data member/instance variable:, amt, : stores the transaction amount in decimals, Member functions/methods:, Account(…), : parameterized constructor to assign values, to the instance variables of both the classes, void deposit(), : accepts the amount and updates the, principal as p=p+amt, void withdraw(), : accepts the amount and updates the, principal as p=p-amt, If the withdrawal, amount is more than the principal, amount, then display the message, “INSUFFICIENT BALANCE”. If the principal, amount after withdrawal is less than 500,, then a penalty is imposed by using the, formula. p=p-(500-p)/10, void display(), : displays the details of the customer, Assume that the superclass Bank has been defined., Using the concept of Inheritance; specify the class Account, giving details of the constructor(…), void deposit(), void, withdraw() and void display(). The superclass and the main, function need not be written., , COMBINED ISC 135 Page 9