create a simple program that will calculate the total amount due, accept payment, and display the change
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter the price: ");
int A=input.nextInt();
int Amount=A*2;
System.out.println("Enter the payment: ");
int X=input.nextInt();
int change=X-Amount;
if(X>A){
System.out.println("The change is: "+change);
}
else{
System.out.println("Payment is less");
}
}
}
Comments
Leave a comment