Hi ,
//In this project, you’ll create a program that calculates a salesperson’s commissions using double-precision values,
and displays the results. The commission rate in the first
method will be entered as a decimal value (for example,
a 7.5% rate will be entered as 0.075).
I read javaAddict reply here : http://www.daniweb.com/forums/thread132264.html for the same school project I have.
The reply das not explaine how you can input 0.075 which is decimal value in the "int rate = ?; whitout errors
//In this project, you’ll create a program that calculates a
salesperson’s commissions using double-precision values,
and displays the results. The commission rate in the first
method will be entered as a decimal value (for example,
a 7.5% rate will be entered as 0.075).
public class Commission {
public static void main(String[] args){
double sales = 30000.0;
double commission = 0.0;
int rate = 0.075;commission = computeCommission(sales, rate);
System.out.println("Commission on sales of "
+ sales
+ " with a rate of " + rate + "%"
+ " is "
+ commission);
double drate = 7;
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);
}
}
// How will I able enter the 0.075 in the int rate = 0.075; without error being generated?
Please if you have knowlige how it works can you help me?
Thank you
Hanz