Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Problem Statement 1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
public class MathOperation {
int firstNumber;
double doubleValue;
String text;

public void printCalculatedSum(int number1, int number2) {
int sum = number1 + number2;
System.out.println("Sum: " + sum);
}

public void printStringIntoUppercase(String oldString) {
String uppercaseString = oldString.toUpperCase();
System.out.println("String: " + uppercaseString);
}
}

public class MainProgram {
public static void main(String[] args) {
MathOperation mathOperation = new MathOperation();

mathOperation.firstNumber = 10;
mathOperation.doubleValue = 20.5;
mathOperation.text = "hello";

mathOperation.printCalculatedSum(mathOperation.firstNumber, 5);

mathOperation.printStringIntoUppercase("world");
}
}
97 changes: 97 additions & 0 deletions Problem Statement 2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Product {
private String name;
private double price;
private int quantity;

public Product(String name, double price, int quantity) {
this.name = name;
this.price = price;
this.quantity = quantity;
}

public String getName() {
return name;
}

public double getPrice() {
return price;
}

public int getQuantity() {
return quantity;
}

public void setQuantity(int newQuantity) {
this.quantity = newQuantity;
}
}

class InventoryManager {
private List<Product> productList;

public InventoryManager() {
this.productList = new ArrayList<>();
}

public void addProduct(Product product) {
productList.add(product);
}

public List<Product> getInventory() {
return productList;
}
}

public class InventorySystem {
public static void main(String[] args) {
InventoryManager inventoryManager = new InventoryManager();
Scanner scanner = new Scanner(System.in);

while (true) {
System.out.println("\nInventory Management System");
System.out.println("1. Add Product");
System.out.println("2. Display Inventory");
System.out.println("3. Exit");
System.out.print("Enter your choice: ");

int choice = scanner.nextInt();

switch (choice) {
case 1:
System.out.print("Enter product name: ");
String productName = scanner.next();
System.out.print("Enter product price: ");
double productPrice = scanner.nextDouble();
System.out.print("Enter product quantity: ");
int productQuantity = scanner.nextInt();

Product newProduct = new Product(productName, productPrice, productQuantity);
inventoryManager.addProduct(newProduct);

System.out.println("Product added successfully!");
break;

case 2:
System.out.println("\nCurrent Inventory:");
List<Product> products = inventoryManager.getInventory();
for (Product product : products) {
System.out.println("Name: " + product.getName() +
", Price: $" + product.getPrice() +
", Quantity: " + product.getQuantity());
}
break;

case 3:
System.out.println("Exiting program. Goodbye!");
System.exit(0);

default:
System.out.println("Invalid choice. Please enter a valid option.");
}
}
}
}