Home Show/Hide Menu
Bluej Programs
➜ Test-paper-IT-10
➜ Suggestion Paper, Class-12

bluej Programs

4.Write a program that will enter cost amount and selling amount. Calculate the profit or loss occurred .

import java.util.*;
class ProfitLoss
{
    void main()
    {
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter the Cost Price:");
    int cp=sc.nextInt();
    System.out.println("Enter the Selling Price:");
    int sp=sc.nextInt();
    if(cp>sp)
    System.out.println("Loss");
    else if(sp>cp)
    System.out.println("Profit");
    else
    System.out.println("No Profit No Loss");
    }
    
    
}


Output:
Enter the Cost Price:
678
Enter the Selling Price:
876
Profit

 
ADVERTISEMENT