Aman Java Exp 2.1
Aman Java Exp 2.1
Experiment 2.1
Student Name: Aman Kumar UID: 23BCS12527
Branch: BE-CSE Section/Group: 608-B
Semester: 4th Date: 18/02/2025
Subject Name: OOPs using Java Subject Code: 23CSP-202
1. Aim:
The business sells electronic gadgets, and the owner needs to calculate the profit for
each product based on its revenue and cost. The program consists of two classes: The
Business Class, which handles user input for multiple products, prompts the user for
revenue and cost, and uses the Profit class to calculate and display the profit for each
product. The Profit Class calculates the profit using the formula.
Formula:
Profit = Revenue - Cost
With a constructor to initialize the values and a method to compute the profit. The
profit for each product should be displayed formatted to two decimal places.
2. Objective:
The objective of this project is to develop a Java program that calculates and
displays the profit for each electronic gadget using user-provided revenue and cost.
It utilizes two classes—Business for handling input and display, and Profit for
computing profit using the formula: Profit = Revenue - Cost, formatted to two
decimal places.
3. Java Code:
import java.util.Scanner;
// Main method
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
scanner.close();
}
}
4. Output: