Computer Science, asked by Naitikduggad, 10 months ago

Write a program 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 per cent otherwise,
calculate and display actual loss and loss per cent. If the cost price and the selling price are equal,
the program displays the message 'Neither profit nor loss'.

Answers

Answered by pratyushsharma697
43

Answer:

import java.util.*;

public class brainly

{

public static void main (String args [])

{

Scanner in=new Scanner (System.in);

int sp,cp,p,l;

double pp,lp;

System.out.println ("Enter the cost price and selling price of an article");

cp=in.nextInt ();

sp=in.nextInt ();

if (sp > cp)

{

p=sp-cp;

pp=p*100.0/cp;

System.out.println("The profit is:"+p);

System.out.println ("The profit percent="+pp);

}

else if (sp <cp)

{

l=cp-sp;

lp=l*100.0/cp;

System.out.println("The loss :"+l);

System.out.println ("The loss percent:"+lp);

}

else

System .out.println ("neither profit nor loss");

}

}

Hope it helps!!!

Plz mark it as brainliest..... !!

Similar questions