Вы находитесь на странице: 1из 1

Exercise Sets

1. Create a calculator class which will have methods add, multiply, divide &
subtract.

2. Create a Student class with attributes studentName, rollNo, ec1Marks,


ec2Marks, ec3Marks. The Student class has a behavior Average which would
return the average of the 3 scores (ec1Marks,ec2Marks & ec3Marks) & return
“pass” or “fail” based on whether the score is greater than or equal to 50, or
less than 50 respectively.

3. Create a Bank class which has attributes accountNo, balance. This class should
have behavior Deposit & Withdraw.
The behavior Deposit would accept the depositedAmt as argument & return
the newBalance equal to the sum of the previous balance & the depositedAmt.

Similarly, the Withdraw method would accept the withdrawAmt as argument


& return the newBalance equal to the withdrawAmt subtracted from the
previous balance.
If the withdrawAmt is greater than the previous balance, it should return -1.

Use necessary getters & setters.

4. Create a class Circle which has radius as its attribute. Provide methods Area() &
Perimeter() which would calculate Area & Perimeter respectively.

5. Define a class TaxCalculator with annualIncome, InvestedAmount, sex and


PanNumber as properties. Define a behavior to calculate tax for the
PanNumber. (Hint: Taxable amount = Annual Income - Invested amount.
Given below the tax rates based on the taxable amount.

0 to 2000 : Tax=0%
2001 to 5000 : Tax=2% over the excess of 2000
5001 to 10000 : Tax=60+4% over the excess of 5000
10001 to 15000 : Tax=260+6% over the excess of 10000
15001 to 20000 : Tax=560+8% over the excess of 15000
20001 to 3000 : Tax=960+10% over the excess of 15000
30001 to 50000 : Tax=1960+12,5% over the excess of 15000
greater than 50001 : Tax=4460+15% over the excess of 15000

6. Define a class called Electronics with properties regularPrice & manufacturer.


Provide behaviors computeSalePrice which would return the salePrice which is
regularPrice multiplied by 0.6, getManufacturer to return the manufacturer &
setManufacturer to change the manufacturer.

Вам также может понравиться