Answer:
The program in Java is as follows:
import java.util.Scanner;
public class MyClass {
public static void main(String args[]) {
double bill;
Scanner input = new Scanner(System.in);
System.out.print("Enter the original bill amount : ");
bill = input.nextDouble();
if(bill>2000){
bill-=0.15*bill;
}
System.out.println("Bill after discount: " + bill);
}
}
Step-by-step explanation:
This declares bill as double
double bill;
This lets the program accept input
Scanner input = new Scanner(System.in);
This prompts user for the original bill amount
System.out.print("Enter the original bill amount : ");
This gets the bill from the user
bill = input.nextDouble();
This checks if the input bill is greater than 2000
if(bill>2000){
If yes, the bill after discount is calculated as follows:
bill-=0.15*bill;
}
This prints the bill after discount
System.out.println("Bill after discount: " + bill);