Java Chapters

Java Program to find the cost price of one item, if the total selling price of 15 items and the total profit earned on them is input through the keyboard.

Structure of JAVA Programs - Overview
import java.util.Scanner;

public class Program 
{
    public static void main( String[] args ) 
    {
        float SP, Profit, CP;
        Scanner reader = new Scanner(System.in);
        
        System.out.println("Enter Total Selling Price and Profit : ");
        SP = reader.nextFloat();
        Profit = reader.nextFloat();
        
        CP = SP - Profit;
        CP = CP / 15;
        
        System.out.println("\nCost Price per Item is : " + CP);
    }
}

Output :
Enter Total Selling Price and Profit : 100
20

Cost Price per Item is : 6

Leave a comment
Recent Comments
No Comments