Write a java program using input stream reader to input the cost price and the selling price of an article . if the selling price is more than the cost price then calculate and display actual profit and profit percent otherwise, calculate and display actual loss and loss percent . if the cost price and selling price are equal the program displays the message “ neither profit nor loss”.
Answers
Answered by
4
Explanation:
import java.util.*;
public class Solution
{
public static void main(String args[])
{
Scanner In = new Scanner(System.in);
float CP,SP,calc;
System.out.println("Enter the cost Price ");
CP = In.nextFloat();
System.out.println("Enter the selling Price ");
SP = In.nextFloat();
if(SP > CP)
{
calc = SP-CP/CP *100;
System.out.println("Profit : "+(SP-CP)+"\nProfit percentage : "+calc);
}else if(CP == SP)
{
System.out.println("neither profit nor loss");
}else
{
calc = CP-SP/CP *100;
System.out.println("Loss : "+(CP-SP)+"\nLoss percentage : "+calc);
}
}
}
Similar questions