The document defines 5 Java classes:
1) A Student class with attributes like name, age, marks, and methods to calculate average and maximum marks and display student details.
2) A ProfitLoss class with constructor, input method to assign cost and selling prices, and display method to calculate profit/loss percentage.
3) An Employee class with attributes like PAN number, name, income, tax, and methods to calculate tax based on income slabs and display employee details.
4) A Salary class with attributes like name, address, salary, tax, and methods to calculate annual tax above a threshold and display staff details with tax.
5) A Discount class with attributes like name,
The document defines 5 Java classes:
1) A Student class with attributes like name, age, marks, and methods to calculate average and maximum marks and display student details.
2) A ProfitLoss class with constructor, input method to assign cost and selling prices, and display method to calculate profit/loss percentage.
3) An Employee class with attributes like PAN number, name, income, tax, and methods to calculate tax based on income slabs and display employee details.
4) A Salary class with attributes like name, address, salary, tax, and methods to calculate annual tax above a threshold and display staff details with tax.
5) A Discount class with attributes like name,
Data members/instance variables: name, age, m1, m2, m3 (marks in three subjects), maximum, average Member methods: (i) A parameterized constructor to initialize the data members (ii) To accept the details of a student (iii) To compute the average and maximum out of three marks (iv) To display the name, age, marks in three subjects, maximum and average. Write a main method to create an object of the class and call the above member methods.
Q2. Design a class with the following specifications:
Class name : profit_loss Data members / instance variables : int cp, sp Members methods : profit_loss ( ) : default constructor to initialize cp, sp void input (int m, int n) : to assign m with cp and n with sp void display ( ) : to calculate and display either profit percent (pp) or loss percent (lp).
Q3. Define a class Employee having the following description :
Instance variables : int pan – to store personal account number String name – to store name double taxIncome – to store annual taxable income double tax – to store tax that is calculated Member functions : Employee ( ) – a default constructor to initialize the pan number, name, taxable income with user input calc( ) – Calculate tax for an employee
Total Annual Taxable Income Tax Rate
Upto Rs, 1,00,000 No tax From 1,00,001 to 1,50,000 10% of the income exceeding Rs. 1,00,000 From 1,50,001 to 2,50,000 Rs. 5000 + 20% of the income exceeding Rs. 1,50,000 Above Rs. 2,50,000 Rs. 25,000 + 30% of the income exceeding Rs. 2,50,000
display ( ) – Output details of an employee as per given format
Output : Pan Number Name Tax-income Tax __ __ __ __ __ __ __ __
Q4. Define a class Salary described as below: -
Data Members: name, address, phone, monthly salary, income tax. Member methods: Salary() - Default constructor to initialize name, address, phone and monthly salary void calc() - To compute the annual income tax as 15% of the annual salary above ₨.1,75,000. void display() - To display the details of the staff along with the income tax.
Q5. Define a class Discount as described below:
Data members/instance variables: name, price, dis, amt Member methods: i) A parameterized constructor to initialize the data members ii) To accept the details (Name of the customer and the price of the laptop) iii) To compute the discount.
Category Discount on Laptop
Up to ₹ 25,000 5% ₹ 25,001 – ₹ 50,000 7.5% ₹ 50,001 – ₹ 1,00,000 10% More than ₹ 1,00,000 15%
iv) To display the name, discount and amount to be paid after discount. Write a main method to create an object of the class and call the above member methods.