Sunday 16 August 2015

WAP in java to accept cost price and selling price of an item and determine whether the profit or loss will be there and also determine how much profit or loss incurred.

//Determine whether(and how much) profit or loss is incurred

import java.util.Scanner;

class ProfitOrLoss {

public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter Selling Price and Cost Price(respectively):");
float sp=sc.nextFloat();
float cp=sc.nextFloat();

if(sp==cp)
System.out.println("Neither profit nor loss");
else if(sp>cp)
System.out.println("Profit="+(sp-cp));
else
System.out.println("Loss="+(cp-sp));
}


}

No comments:

Post a Comment