I want to know if this is correct for what they are asking. If I try to put 7.5% in the int=
spot it errors. I am a newbie who doesn't quite understand it all.
The commission rate in the firstmethod will be entered as a decimal value (for example,
a 7.5% rate will be entered as 0.075).A second method will be included that takes the same salesvalue as the first method, but has the commission rate entered as an integer (for example, 7 would be entered for 7%.). This commission value is then divided by 100.0, the
sales figure is multiplied by the result of that calculation,and the final result is displayed to the user.
public class Commission
{
public static void main(String[] args)
{
double sales = 45000.0;
double commission = 0.0;
int rate = 5;
commission = computeCommission(sales, rate);
System.out.println("Commission on sales of "
+ sales
+ " with a rate of " + rate + "%"
+ " is "
+ commission);
double drate = 7.5;
commission = computeCommission(sales, drate);
System.out.println("Commission on sales of "
+ sales
+ " with a rate of " + drate + "%"
+ " is "
+ commission);
}
public static double computeCommission(double s, double r)
{
return (( (double) r / 100.0) * s);
}
public static double computeCommission(double s, int r)
{
return (( (double) r / 100.0) * s);
}
}