Good day, I make a method with a discount on the number but the one percent discount does not work . Problem with rounding numbers ?
Waiting: price 65.
Reality: price 66.
CODE:
public class Main {
public static void main(String[] args) {
int discount = 1;
int price = 66;
price -= (int) (discount * (price / 100));
System.out.println(price);
}
}
Please tell me how to round it down ?
SOLUTION:
public class Main {
public static void main(String[] args) {
int discount = 1;
int price = 66;
double amountOfDiscount = (discount * (price / 100.0f));
double priceWithDiscountDoubleType = (price - amountOfDiscount);
int priceWithDiscount = (int)
Math.floor(priceWithDiscountDoubleType);
System.out.println(priceWithDiscount);
}
}