I am trying to use the Decimal.Format to multiply a double price; by a discount using a 2 digit int, not a double, to get the double salePrice.
I think the only error I have is in the multiplication to produce the sales price.
Here is my code.
double price;
int discount;
double salePrice;
DecimalFormat money = new DecimalFormat("$0.00");
price = Double.parseDouble(Greenfoot.ask("What is the price of the product"));
discount = Integer.parseInt(Greenfoot.ask("What is the amount of the discount? Use a two digit number such as 30"));
// process the Double price multiplied by the two intiger discount, to output th sale price
salePrice = (double price)*(discount);
showText("Price: " + money.format(price), getWidth()/2, getHeight()/2);
showText("Discount: " + money.format(discount) , getWidth()/2, getHeight()/2 - 20);
showText("Sale Price: " + money.format(salePrice), getWidth()/2, getHeight()/2 - 40);
Greenfoot.stop();

