EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

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

Java program practice questions

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer