-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
71 lines (62 loc) · 3.11 KB
/
Copy pathMain.java
File metadata and controls
71 lines (62 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public class Main {
public static void main(String[] args) {
System.out.println("========================================");
System.out.println(" Student Product Billing & Management ");
System.out.println("========================================\n");
// US-01: Student Object
System.out.println(">>> US-01: Student Object Creation <<<");
Student student1 = new Student();
student1.rollNo = 101;
student1.name = "Aarav Sharma";
student1.marks = 88.5;
student1.displayDetails();
// US-02: String Formatting
System.out.println("\n>>> US-02: String Formatting <<<");
student1.displayNameFormats();
// US-03: Marks Array
System.out.println("\n>>> US-03: Marks Array of 5 Students <<<");
double[] marksArray = {85.5, 90.0, 78.0, 92.5, 88.0};
for (int i = 0; i < marksArray.length; i++) {
System.out.println("Student " + (i + 1) + " Marks: " + marksArray[i]);
}
double total = 0;
for (int i = 0; i < marksArray.length; i++) { total += marksArray[i]; }
System.out.println("Average Marks: " + (total / marksArray.length));
// US-04: Method Overloading
System.out.println("\n>>> US-04: Product Billing (Method Overloading) <<<");
ProductBilling billing = new ProductBilling();
double bill1 = billing.calculateBill(500.0);
System.out.println("Total Bill (1 product) : Rs. " + bill1);
double bill2 = billing.calculateBill(500.0, 300.0);
System.out.println("Total Bill (2 products) : Rs. " + bill2);
double bill3 = billing.calculateBill(500.0, 300.0, 200.0);
System.out.println("Total Bill (3 products) : Rs. " + bill3);
System.out.println("After 10% Discount : Rs. " + billing.applyDiscount(bill3, 10));
// US-05 & US-06: Employee
System.out.println("\n>>> US-05 & US-06: Employee with Constructor and Static <<<");
Employee emp1 = new Employee(201, "Riya Gupta", 55000.0);
emp1.displayDetails();
System.out.println();
Employee emp2 = new Employee(202, "Rahul Verma", 62000.0);
emp2.displayDetails();
// US-07: Encapsulation
System.out.println("\n>>> US-07: Product with Encapsulation <<<");
Product product = new Product();
product.setProductId(301);
product.setProductName("Java Programming Book");
product.setPrice(450.0);
product.displayProduct();
// US-08: Inheritance
System.out.println("\n>>> US-08: Inheritance - CollegeStudent <<<");
CollegeStudent cStudent = new CollegeStudent();
cStudent.rollNo = 501;
cStudent.name = "Priya Singh";
cStudent.marks = 91.0;
cStudent.collegeName = "Delhi Tech College";
cStudent.course = "B.Tech CSE";
cStudent.displayCollegeDetails();
System.out.println("\n========================================");
System.out.println(" Program Completed! ");
System.out.println("========================================");
}
}