Majed Topic Starter
Posts: 3
Experience: Beginner OS: Unknown
|
 |
« on: February 28, 2011, 12:29:12 PM » |
|
1. Design a class to represent a geometric rectangle with a given length and width, such that it is capable of calculating the area and the perimeter of the rectangle.
2. Define a class that represents a Temperature object. It should store the current temperature in an instance variable of type double, and it should have two public methods, setTemp(double t), which assigns t to the instance variable, and getTemp(), which returns the value of the instance variable.
3. Define a class named TaxWhiz that computes the sales tax for a purchase. It should store the current tax rate as an instance variable. You can initialize the rate using a TaxWhiz() method. This class should have one public method, calcTax(double purchase), which returns a double, whose value is purchases times the tax rate. For example, if the tax rate is 4 percent, 0.04, and the purchase is $100, the calcTax() should return 4.0
Many thanks to all of you.
Figure 1.8.
|