If coast price and selling price of an item are input through the keyboard. Write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.

 //.If coast price and selling price of an item are input through the keyboard.

// Write a program to determine  whether the seller has made profit or incurred loss.
// Also determine how much profit he made or loss he incurred.
package com.company;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
// write your code here
int costPrice,sellingPrice,profit,loss;
Scanner sc = new Scanner(System.in);
System.out.print("Enter cost price : ");
costPrice=sc.nextInt();
System.out.print("Enter selling price : ");
sellingPrice= sc.nextInt();
if (sellingPrice>costPrice)
{
profit=sellingPrice-costPrice;
System.out.println("Seller has made profit : "+profit+" ");
}
else
{
loss= costPrice-sellingPrice;
System.out.println("Seller has made loss of : "+loss+" ");
}

}
}
Enter cost price : 20
Enter selling price : 30
Seller has made profit : 10  ₹

Process finished with exit code 0

Comments

Popular posts from this blog

the distance between two cities (in km is input through the keyboard. write a program to convert and print this distance in meter ,feet inches and centimeter.

CREATE UNIT CONVERTER APP

write a program to check whether a triangle is valid or not, when the threeangles of the triangle are entered through the keyboard. A triangle is valid if the sumof all the three angles is equal to 180 degrees