Computer Science, asked by sanjanalokesh7, 4 months ago

write a program to input the cost price and the selling price of an article.If the selling price is more than cost price then calculate and display actual the profit and profit per cent otherwise, calculate and display the actual loss and loss per cent. If the cost price and the selling price are equal, the program display the message
'Neither profit nor loss'.​

Answers

Answered by divyaaptekar33
1

Answer:

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! ");

}

}

}

Similar questions