Write a program to input cost price and selling price of the product, find and display the profit amount as well as profit %.
Answers
Answered by
4
Answer:
import java.util.Scanner; public class KboatProfit { public static void main(String args[]) { Scanner in = new Scanner(System.in); System.out.print("Enter cost price of the article: "); double cp = in.nextDouble(); System.out.print("Enter selling price of the article: "); double sp = in.nextDouble(); double pl = sp - cp; double percent = Math.abs(pl) / cp * 100; if (pl > 0) { System.out.println("Profit = " + pl); System.out.println("Profit % = " + percent); } else if (pl < 0) { System.out.println("Loss = " + Math.abs(pl)); System.out.println("Loss % = " + percent); } else { System.out.println("Neither profit nor loss"); } } }
OUTPUT
Attachments:
Answered by
0
Answer:
{
class abc
{
public void accept ( double CP, double SP)
double P = 0.0 ,double PP =0.0 ;
P = SP - CP;
PP= P / CP *100;
System.out.println ( profit= +P);
System.out.println ( profit%= +PP);
}
}
HOPE IT HELPS YOU.
PLEASE MARK ME AS BRAINLIEST.
Similar questions