Sales Commrate Comrate: Computecommission
Sales Commrate Comrate: Computecommission
Programming Exercises
1. Create a class named Commission that includes 3 variables: a double sales figure, a
double commission rate and an integer commission rate. Create 2 overload methods
named computeCommission(). The first method takes 2 double arguments representing
sales and rate. Multiply them and then display the result. The second method takes 2
arguments: a double sales figure and an integer commission rate. This method must
divide the commission rate by 100.00 before multiplying it by the sales figure. Display
the commission.
import javax.swing.*;
public class Commission{
2. Create a class named Pizza. Data fields include String for toppings, an integer for
diameter in inches and double for price. Include methods to get and set values for each
of these fields.
3. Create a class named TestPizza that instantiates one Pizza object and demonstrates the
use of the Pizza set and get methods.
import javax.swing.JOptionPane;
public class TestPizza // class
{
public static void main (String []args)
{
JOptionPane.showMessageDialog(null,"INFORMATION\n\nTOPPINGS:"+romeo.getTopping
s()+"\nDiameter(inches):"+
romeo.getDiameter()+"\nPrice:"+romeo.getPricer());// to get
the toppings,diameter,price
}}
4. Create a class named Circle with fields named radius, area and diameter. Include
methods named setRadius(), getRadius(), computeDiameter() which computes a circle’s
diameter and computeArea() which computes a circle’s area. The diameter of a circle is
twice its radius and the area is A=π r 2 .
this.radius = Math.abs(radius);
return this.radius;
return this.diameter;
return this.area;
diameter = radius*2;
area = 3.14*radius*radius;
}