To get value from user, use the following code
final double COMMISSION_SOUGHT=Double.parseDouble(args[0]);
actually the "Double.parseDouble()" is used to convert input String type into Double. BUt i dont know how for this syntax works.
If it does not work, use the following syntax:
final int COMMISSION_SOUGHT=Integer.parseInt(args[0]);
And to convert do while into for loop, try this:
int i=0;
for(i=0;commission < COMMISSION_SOUGHT;i++){
salesAmount += 0.01;
if (salesAmount >= 10000.01)
commission =
5000 * 0.08 + 5000 * 0.1 + (salesAmount - 10000) * 0.12;
else if (salesAmount >= 5000.01)
commission = 5000 * 0.08 + (salesAmount - 5000) * 0.10;
else
commission = salesAmount * 0.08;
}
But i am sure that this code wont do the exact work of ur original code. Coz, as u know,do while loop will be executed atleast once.