Computer Science, asked by sumitkumar2920, 1 year ago

write a program in Java to find out profit percentage where selling price and cost price are input through the keyboard

Answers

Answered by hackercall
4
Example....

class ProfitLoss

{

public static void main(String aa[])

{

float CP,SP,profit, loss,profitper,lossper;

CP=1500;SP=1750;

if(SP>CP)

{

profit=SP-CP;

profitper=(profit/CP)*100;

System.out.println("Profit is="+profit);

System.out.println("Profit percentage is"+profitper+"%");

}

else if(CP>SP)

{

loss=CP-SP;

lossper=(loss/CP)*100;

System.out.println("Loss is="+loss);

System.out.println("Loss percentage is"+lossper+"%");

}

else

{

System.out.println("No Profit, No Loss");

}

// it is better to block the last else statement

//instead of let it as a single statement even

//though there will not be any syntax error.

}

}

Similar questions