import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter cost price of an article: ");
double costPrice = keyBoard.nextDouble();
System.out.print("Enter selling price of an article: ");
double sellingPrice = keyBoard.nextDouble();
double diff = sellingPrice - costPrice;
if (diff > 0) {
System.out.println("Profit = " + diff);
} else {
System.out.println("Loss = " + Math.abs(diff));
}
keyBoard.close();
}
}
Comments
Leave a comment