WAP in JAVA to enter the cost price and selling price of an item and print whether that trader has made profit or loss
Answers
Answer:
free shipping on orders over by the meaning of this email and any attachments is intended only for the meaning of this email any attachments is intended only for the meaning of this email and any attachments is intended
Answer:
Java Program to Calculate Profit or Loss Example 1
This program allows the user to enter the actual amount and Sales amount. By using those two values, this Java program checks whether the product is in profit or Loss using Else If Statement.
TIP: Java Else If statement checks the first condition if it is TRUE, it executes the statements inside that block. If the condition is FALSE, it checks the Next one (Else If condition) and so on.
// Java Program to Calculate Profit or Loss
import java.util.Scanner;
public class ProfitorLoss {
private static Scanner sc;
public static void main(String[] args)
{
float saleAmount, unitPrice, amount;
sc = new Scanner(System.in);
System.out.print(" Please Enter the Actual Product Cost : ");
unitPrice = sc.nextFloat();
System.out.print(" Please Enter the Selling Price (Market Price) : ");
saleAmount = sc.nextFloat();
if(saleAmount > unitPrice )
{
amount = saleAmount - unitPrice;
System.out.println("\n Profit Amount = " + amount);
}
else if(unitPrice > saleAmount)
{
amount = unitPrice - saleAmount;
System.out.println("\n Loss Amount = " + amount);
}
else
{
System.out.println("\n No Profit No Loss! ");
}
}
Explanation:
mark as brainlist please