Computer Science, asked by justauser2, 1 year ago

write a java program to input the cost price and the selling price of an article. if the selling price is more than the cost price and then calculate and display actual profit and profit percent otherwise, calculate and display actual loss or loss percent is the cost price in the selling price are equal ,the program displays the message 'neither profit no loss'.

write the program using scanner or inputstreamreader classes..

please don't gave rubbish answers and don't suggest me to google it or anything else like dat..

Answers

Answered by Yravi
74
SOLUTION:import java.io.*;
public class Percentage
{
public static void main(String args[])throws IOException
{
int cp,sp,p,l;
InputStreamReader read=new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter Cost Price");
cp=Integer.parseInt(in.readLine());
System.out.println("Enter Selling Price");
sp=Integer.parseInt(in.readLine());
if (sp>cp)
{
p=sp-cp/cp*100;
System.out.println("Profit Percentage="+p);
}
else if (cp>sp)
{
l=cp-sp/cp*100;
System.out.println("Loss Percentage="+l);
}}}
.
I hope it is helpful to you... :-)

justauser2: tqsm dear!!
Answered by debanjanbala
20

Answer:

classLossOrProfitPercentage

{

public static void main(double a , double b)

{

double k= 0.0;

if(a>b)

{

k= (b-a/100*a)

system.out.println ("Loss Percent" + k)

{

else(a<b)

{

k= (a-b/100*a)

system.out.println("Profit Percent " +k)

}

}

}

Mark me as brainliest.

Similar questions