QUESTION BASED UPON CLASS AND OBJECT

Create a class car which has following methods

  1. A method called input to accept model no. as string and price of the car.
  2. A method called display to display model no. and price of the car.

Create a class book_details which has following methods

  1. A method called input to accept book id as string, book name as string and book price as double from user.
  2. A method called calculate to find discount on book price .The discount will be 4% on book price.
  3. A method called display to display book id,book name, book price,discounted amount and selling price of the book.

Create a class called student having following methods.

1.A method called accept() to accept student id as string,student name as string ,course fee as integer ,installment1 as integer,installment2 as integer and installment3 as integer.You have to accept these value as formal parameter.

2.A method called calculate () to find total installments and balance(Course fee-total installments)

3. A method called display to display student id,student name, course fee ,installment1,installment2 and installment3,total installment and balance.

PROBLEM BASED ON CONSTRUCTOR

Create a class called product having following constructors and methods

  1. A default constructor should initialize all the member data of class.
  2. An overloaded constructor should accept product id as string, product name as string and product cost as double. You have to accept these values as formal parameter.
  3. A method called calculate to provide discount on product price.Criteria is given below to provide discount on product price
  4. If product price lies between 1.00/- and 30.00/- then discount will be 1% of product price.
  5. If product price is greater than 30 then discount will be 2% of product price.
  6. If product price is less than 1 then discount will be 0%;
  7. A method called display to display product id, product name ,product cost ,discount price ,discounted amount and selling price.

Create a class called employee which has following methods and constructors..

  1. A default constructor should initialize all the member data of class.
  2. An overloaded constructor should accept employee id as string, employee name as string and basic salary as double. You have to take input from constructor.
  3. A method called calculate to find ta,da,hra on basic salary as per follow the given criteria:
  4. If salary lies between 4000 and 10000 than ta,da and hra will be 2% of basic salary.
  5. If salary is greater than 10000 and less than or equal to 25000 then ta,da,hra will be 3.5% of basic salary.
  6. If salary is greater than 25000 then ta,da,hra will be 1% of basic salary.
  7. If salary lies between 1 and 3999 then ta,da and hra will be 6% of basic salary
  8. Otherwise generate error message for wrong input such as negative basic salary or 0 salary.

4. A method called display to display employee id,name ,basic salary,ta,hra,da,gross salary.

Create a class called employee which has following methods and constructors..

  1. A default constructor should initialize all the member data of class.
  2. An overloaded constructor should accept employee id as string, employee name as string and basic salary as double. You have to take input from constructor.
  3. A method called calculate to find ta,da,hra on basic salary as per follow the given criteria:
  4. If salary lies between 4000 and 10000 than ta,da and hra will be 2% of basic salary.
  5. If salary is greater than 10000 and less than or equal to 25000 then ta,da,hra will be 3.5% of basic salary.
  6. If salary is greater than 25000 then ta,da,hra will be 1% of basic salary.
  7. If salary lies between 1 and 3999 then ta,da and hra will be 6% of basic salary
  8. Otherwise generate error message for wrong input such as negative basic salary or zero basic salary.
  1. A method called tax_deduct method to deduct tax on gross salary and also find the net salary.Tax deduction will be based on following criteria:-
  2. If gross salary is greater than 10000 then deduct the tax 4%
  3. Else deduct the tax 2%.
  4. A method called display to display employee id, name, basic salary, ta, hra, da, grosssalary, tax amount and net payment.

PROBLEM BASED ON INHERITANCE

Create a class called student_info having following methods.

1.A method called accept() to accept student id as string, student name as string ,course fee as integer ,installment1 as integer,installment2 as integer and installment3 as integer. You have to accept these values as formal parameter.

2.A method called calculate () to find total installments and balance(Course fee-total installments)

Create a class called student_fee that inherits the class student_info which has following method

1. A method called display to display student id, student name, course fee ,installment1, installment2 and installment3,total installment and balance.

Note: Create at least two objects of class student_fee.

PROBLEM BASED ON CALLING BASE CLASS CONSTRUCTOR THROUGH INHERIT CLASS

Create a class called product having following constructors and methods

1. A default constructor should initialize all the member data of class.

  1. An overloaded constructor should accept product id as string, product name as string and product cost as double. You have to accept these values as formal parameter.
  2. A method called display to display product id, product name ,product cost ,discount percentage ,discounted amount and selling price.

Create a class called product_calc that inherits the property of product class and which has following methods and constructor.

  1. A default constructor will call the default constructor of its base class.
  2. An overloaded constructor will call the overloaded constructor of its base class.

3.A method called calculate to provide discount on product price.Criteria is given below to provide discount on product price

  1. If product price lies between 1.00/- and 30.00/- then discount will be 1% of product price.
  2. If product price is greater than 30.00 then discount will be 2% of product price.
  3. If product price is less than 1 then display error message that product price must be greater than or equal to 1.00.

Note:

  1. Use of this and base reserve keyword is required.
  2. Create five objects of product_calc class by using an array.

CALLING OVERLOADED METHOD THROUGH INHERITANCE

Create a class called employee which has following methods

  1. A method called accept should accept employee id as string, employee name as string and basic salary as double, as formal parameter.
  2. A method called accept to find ta,da,hra on basic salary as per follow the given criteria:
  3. If salary lies between 4000 and 10000 than ta,da and hra will be 2% of basic salary.
  4. If salary is greater than 10000 and less than or equal to 25000 then ta,da,hra will be 3.5% of basic salary.
  5. If salary is greater than 25000 then ta,da,hra will be 1% of basic salary.
  6. If salary lies between 1 and 3999 then ta,da and hra will be 6% of basic salary
  7. Otherwise generate error message for wrong input such as negative basic salary or zero basic salary.

Create a class employee_tax that inherits the properties of employee class which has following methods

1. A method called tax_deduct method to deduct tax on gross salary and also find the net salary.Tax deduction will be based on following criteria:-

  1. If gross salary is greater than 10000 then deduct the tax 4%
  2. Else deduct the tax 2%.
  1. A method called display to display employee id, name, basic salary,

ta, hra, da, gross salary, tax amount and net payment.

PROBLEM BASE ON INHERITANC AND INTERFACE

1.Create an interface called inter1 which has only one abstract method i.e input() method.

This method has two formal parameters to accept student id as string and student name as string.

2.Create an interface called inter2 which has only one abstract method called display(). Inter2 interface inherits the property of inter1 interface.

3. Create a class called student_info that implements the interface inter2 and also it has following constructor

a) The default constructor will initialize all the variables.

b) An overloaded constructor will accept student id as string, student name as string and also course fee as integer.

This constructor is responsible to execute both the implemented method input and display. Here display () method will display student id,student name,course fee and discount.

Create a class called student_child that inherits all the properties of student_info.It has following constructor and methods.

1)the default constructor will initialized all the variables

2)a method called calculate() to provide 4% discount on course fee.

3)A method called display () to display the new course fee and also it will execute the super class display method.

PROBLEM BASED ON ABSTRACT CLASS

Create an abstract class,class name is abs_prod which has following methods

  1. A method called calculate() that provides 4% discount on product cost.
  2. An abstract method is called input() which helps the derived class to take three formal parameters such as product id,product name and product cost.
  3. An abstract method is called display() that helps the derived class to display product id ,product name ,product cost and selling price.
  4. Create a class called product that inherits the class abs_prod that will use all the properties of abs_prod class.