Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

WELCOME TO

MY
PRESENTATION
PRESENTED BY

MD. LIMON YUSUF

230221019

DEPARTMENT OF CSE

EUROPEAN UNIVERSITY OF
BANGLADESH
ONLINE
SUPERSHOP
MANAGEMEN
T
OBJECCTIVES

• Admin • Product • Customer • Product


Panel Information Information Category

• Payment • Print
• Total Price
Method Information
Code For Product Information
public class Product {
private int id;
private String name;
private double price;
private int quantity;

public Product(int id, String name, double price, int quantity) {


this.id = id;
this.name = name;
this.price = price;
this.quantity = quantity;
}
Continued…
Continued
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
Continued
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
Continued
public void displayProductDetails() {
System.out.println("Product ID: " + id);
System.out.println("Product Name: " + name);
System.out.println("Product Price: $" + price);
System.out.println("Product Quantity: " + quantity);
}
public static void main(String[] args) {
Product product = new Product(1, "Laptop", 999.99, 10);

product.displayProductDetails();
}
}
Java program outcomes of undermentioned
problems.
 To find sum of all array elements
 To find maximum and minimum element in an array.
 To find second largest element in an array.
 To count total number of even and odd elements in an array.
 To print all negative elements in an array.
1. Write a Java program to find sum of all array elements .

public class SumOfArrayElements {

public static void main(String[] args) {

int[] array = {1, 2, 3, 4, 5};

int sum = 0;

for (int i = 0; i < array.length; i++) {

sum += array[i];

System.out.println("Sum of array elements: " + sum);

}
2. Write a java program to find maximum and minimum element
in an array.
public class MaxMinArrayElements {
public static void main(String[] args) {
int[] array = {10, 5, 7, 2, 15};
int max = array[0];
int min = array[0];

for (int i = 1; i < array.length; i++) {


if (array[i] > max) {
max = array[i];
}
Continued..
if (array[i] < min) {
min = array[i];
}
}

System.out.println("Maximum element in the array: " + max);


System.out.println("Minimum element in the array: " + min);
}
}
3. Write a java program to find second largest
element in an array
public class SecondLargestElement {
public static void main(String[] args) {
int[] array = {10, 5, 7, 2, 15};
int largest = Integer.MIN_VALUE;
int secondLargest = Integer.MIN_VALUE;

for (int i = 0; i < array.length; i++) {


if (array[i] > largest) {
secondLargest = largest;
largest = array[i];
}
Continued..
else if (array[i] > secondLargest && array[i] != largest) {
secondLargest = array[i];
}
}
if (secondLargest == Integer.MIN_VALUE) {
System.out.println("There is no second largest element.");
} else {
System.out.println("Second largest element in the array: " + secondLargest);
}
}
}
4. Write a java program to count total number of even
and odd elements in an array
public class EvenOddCount {
public static void main(String[] args) {
int[] array = {10, 5, 7, 2, 15};
int evenCount = 0;
int oddCount = 0;
for (int i = 0; i < array.length; i++) {
if (array[i] % 2 == 0) {
Continued..
evenCount++;
} else {
oddCount++;
}
}

System.out.println("Total even elements: " + evenCount);


System.out.println("Total odd elements: " + oddCount);
}
}
5. Write a java program to print all negative
elements in an array.
public class NegativeElements {
public static void main(String[] args) {
int[] array = {-10, 5, -7, 2, -15};

System.out.println("Negative elements in the array:");


for (int i = 0; i < array.length; i++) {
if (array[i] < 0) {
System.out.println(array[i]);
}
• }
• }
•}
Thank You For
your attention

You might also like