The MRP of a mobile phone is Rs.16000. A discount of Rs.2000 is applied on it. Write a java
program to find the selling price taking the MRP as input using scanner class.
Answers
Explanation:
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");
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");
Explanation: