Java program to calculate discount
Following program shows you how to calculate discount.
In this program we get bill amount and discount from user and shows after discount amount using following formula
Discount = bill - (bill * discount / 100)
import java.util.Scanner;
public class BasicMath19 {
public static void main(String[] args) {
int bill;
int discount;
Scanner in = new Scanner(System.in);
System.out.println("Enter bill amount:");
bill = in.nextInt();
System.out.println("Enter discount percentage:");
discount = in.nextInt();
int afterDiscount = bill - (bill * discount / 100);
System.out.println("After discount your bill is: " + afterDiscount);
}
}
Output:
Enter bill amount:
1000
Enter discount percentage:
20
After discount your bill is: 800