Here’s a simple Java program to calculate the cost price of one item, based on total selling price and profit
import java.util.Scanner;
public class CostPriceCalculator {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Input total selling price and profit
System.out.print(“Enter total selling price of 15 items: “);
int sellingPrice = sc.nextInt();
System.out.print(“Enter total profit: “);
int profit = sc.nextInt();
// Calculate total cost price
int totalCostPrice = sellingPrice – profit;
// Cost price of one item
int costPricePerItem = totalCostPrice / 15;
System.out.println(“Cost price of one item = ₹” + costPricePerItem);
}
}
📌 Sample Input/Output:
Input:
Enter total selling price of 15 items: 200
Enter total profit: 50
Output:
Cost price of one item = ₹10