In calculating profit percent(%) and loss percent(%) we will learn about the basic concepts of profit and loss
The price, at which an article(product) is purchased, is called its cost price(C.P)( how much the item cost the shop owner.)
The price, at which an article(product) is sold, is called its selling prices(S.P).( what he is selling it for.)
Profit or Gain:
If Selling Price(S.P) is greater than Cost Price( C.P), the seller is said to have a profit or gain.
If Selling Price(S.P) is less than Cost Price(C.P) the seller is said to have incurred a loss.
- Gain = (S.P.) - (C.P.)
- Loss = (C.P.) - (S.P.)
public static void main(String aa)
float CP,SP,profit, loss,profitper,lossper;
System.out.println("Profit percentage is"+profitper+"%");
System.out.println("Loss percentage is"+lossper+"%");
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.
The if-else statement can be connected to more if-else or if statement to form a chain of if statements. This is called concatenating if-else-if. Any one of the block will be executed and never all of them.