Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
19 views
Implementation of Java Program To Demonstrate Aggregation and Composition
Uploaded by
harsita
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Implementation of Java Program to Demonstrate Aggr... For Later
Download
Save
Save Implementation of Java Program to Demonstrate Aggr... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
19 views
Implementation of Java Program To Demonstrate Aggregation and Composition
Uploaded by
harsita
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download now
Download
Save Implementation of Java Program to Demonstrate Aggr... For Later
Carousel Previous
Carousel Next
Save
Save Implementation of Java Program to Demonstrate Aggr... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 4
Search
Fullscreen
IMPLEMENTATION OF JAVA PROGRAM TO DEMONSTRATE
AGGREGATION AND COMPOSITION
PROGRAM CODE:
class Salary {
double m_salary;
double other;
Salary(double m, double o) {
this.m_salary = m;
this.other = o;
}
Salary(double m) {
this(m, 0);
}
double totalSalary() {
return m_salary + other;
}
}
class Wages {
double home_wages;
double repair_charges;
double medicinal_wages;
Wages(double wages, double charges, double medicine) {
this.home_wages = wages;
this.repair_charges = charges;
this.medicinal_wages = medicine;
}
Wages(double wages) {
this(wages, 0, 0);
}
double totalWages() {
return home_wages + repair_charges + medicinal_wages;
}
}
class Savings {
double tsalary;
double twages;
Savings(double sala, double wage) {
this.tsalary = sala;
this.twages = wage;
}
Savings(double sala) {
this(sala, 0);
}
double savingsEarned() {
return tsalary - twages;
}
}
class Worker {
private Salary salary;
private Wages wages;
Worker(Salary salary, Wages wages) {
this.salary = salary;
this.wages = wages;
}
double totalIncome() {
return salary.totalSalary() + wages.totalWages();
}
}
class Finance {
private Worker worker;
private Savings savings;
Finance(Worker worker, double expenses) {
this.worker = worker;
this.savings =new Savings(worker.totalIncome(), expenses);
}
void displayFinancialSummary() {
double totalIncome = worker.totalIncome();
double totalSavings = savings.savingsEarned();
System.out.println("Total Income: " + totalIncome);
System.out.println("Total Savings: " + totalSavings);
}
}
public class Exp4 {
public static void main(String[] args) {
Salary sal = new Salary(32000, 5000);
Wages wag = new Wages(20000, 3000, 5000);
Salary sal2 = new Salary(35000);
Wages wag2 = new Wages(15000);
Worker worker1 = new Worker(sal, wag);
Worker worker2 = new Worker(sal2, wag2);
Finance finance1 = new Finance(worker1, 33000);
Finance finance2 = new Finance(worker2, 11370);
System.out.println("Financial Summary for Worker 1:");
finance1.displayFinancialSummary();
System.out.println("Financial Summary for Worker 2:");
finance2.displayFinancialSummary();
}}
OUTPUT:
You might also like
s1 Agile User Guide v2
PDF
100% (1)
s1 Agile User Guide v2
104 pages
HCIA-5G V2.0 Exam Outline
PDF
No ratings yet
HCIA-5G V2.0 Exam Outline
2 pages
Implementation of Java Program To Demonstrate Method Overloading and Constructor Overloading
PDF
No ratings yet
Implementation of Java Program To Demonstrate Method Overloading and Constructor Overloading
8 pages
Implementation of Java Program To Pass Arguments To A Method and Return Value
PDF
No ratings yet
Implementation of Java Program To Pass Arguments To A Method and Return Value
8 pages
Implementation of Java Program To Demonstrate File Handling and Object Serialization
PDF
No ratings yet
Implementation of Java Program To Demonstrate File Handling and Object Serialization
8 pages
Implementation of Java Program To Demonstrate Exception Handling
PDF
No ratings yet
Implementation of Java Program To Demonstrate Exception Handling
6 pages
Koustubh Javapraticalassignment1
PDF
No ratings yet
Koustubh Javapraticalassignment1
14 pages
Prova Av2
PDF
No ratings yet
Prova Av2
11 pages
PGM 3
PDF
No ratings yet
PGM 3
1 page
Assignment# 2
PDF
No ratings yet
Assignment# 2
5 pages
Rules/naming Convention's We Need To Follow While Writing The Program
PDF
No ratings yet
Rules/naming Convention's We Need To Follow While Writing The Program
4 pages
Person
PDF
No ratings yet
Person
3 pages
EXP (4)-2
PDF
No ratings yet
EXP (4)-2
9 pages
Personal Finance Tracker
PDF
No ratings yet
Personal Finance Tracker
5 pages
Assignment - 3
PDF
No ratings yet
Assignment - 3
5 pages
OOP_Answer-Key
PDF
No ratings yet
OOP_Answer-Key
15 pages
Java
PDF
No ratings yet
Java
5 pages
Lab Polymorphism
PDF
No ratings yet
Lab Polymorphism
6 pages
Oop 3 Fa20-Be-012
PDF
No ratings yet
Oop 3 Fa20-Be-012
19 pages
Employee Oop Example
PDF
No ratings yet
Employee Oop Example
5 pages
Apex Codes-Day 1 & 2
PDF
No ratings yet
Apex Codes-Day 1 & 2
11 pages
Java 3 & 4
PDF
0% (1)
Java 3 & 4
50 pages
Homework #1: Please Refer To The Code in The Appendix (Pages 2 - 6) To Answer The Following Questions
PDF
No ratings yet
Homework #1: Please Refer To The Code in The Appendix (Pages 2 - 6) To Answer The Following Questions
5 pages
programmed assessment
PDF
No ratings yet
programmed assessment
6 pages
Java_Tasks_Report (1)
PDF
No ratings yet
Java_Tasks_Report (1)
4 pages
program on this keyword
PDF
No ratings yet
program on this keyword
2 pages
PP 2 Brian Sankey
PDF
No ratings yet
PP 2 Brian Sankey
4 pages
Java Project Report On Employee Management System
PDF
100% (1)
Java Project Report On Employee Management System
16 pages
Solution Lab Mini Project Java
PDF
No ratings yet
Solution Lab Mini Project Java
2 pages
Java Output
PDF
No ratings yet
Java Output
8 pages
public class Exercise14
PDF
No ratings yet
public class Exercise14
5 pages
Renzie
PDF
No ratings yet
Renzie
2 pages
Neelu
PDF
No ratings yet
Neelu
14 pages
Class Employee
PDF
No ratings yet
Class Employee
2 pages
Payroll System Final
PDF
No ratings yet
Payroll System Final
7 pages
Midterm Exam Set Two II
PDF
No ratings yet
Midterm Exam Set Two II
2 pages
ASS3
PDF
No ratings yet
ASS3
11 pages
CODER
PDF
No ratings yet
CODER
14 pages
Computer Project Class 12th
PDF
No ratings yet
Computer Project Class 12th
91 pages
SalaryComponent
PDF
No ratings yet
SalaryComponent
2 pages
C#Lab5 7
PDF
No ratings yet
C#Lab5 7
8 pages
Java pgm 10-18
PDF
No ratings yet
Java pgm 10-18
24 pages
Assignment 01
PDF
No ratings yet
Assignment 01
7 pages
Chapter-Seven: Object-Oriented Implementation
PDF
No ratings yet
Chapter-Seven: Object-Oriented Implementation
23 pages
Question # 1: Assignment # 1 (OOP C#)
PDF
No ratings yet
Question # 1: Assignment # 1 (OOP C#)
16 pages
Lab 7
PDF
No ratings yet
Lab 7
29 pages
Assignments Pooja Gaikwad
PDF
No ratings yet
Assignments Pooja Gaikwad
23 pages
PF lab 9
PDF
No ratings yet
PF lab 9
5 pages
Lucrarea de Laborator Nr. 3: Raport La
PDF
No ratings yet
Lucrarea de Laborator Nr. 3: Raport La
12 pages
2.2 Employee
PDF
No ratings yet
2.2 Employee
1 page
المستند
PDF
No ratings yet
المستند
3 pages
Esaimen Ooop
PDF
No ratings yet
Esaimen Ooop
9 pages
Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A
PDF
No ratings yet
Oop Assignment 01: Name: Ghazanfar Qarshi ROLL NO: 2020-BSCS-019 Sec: A
9 pages
Java Program Employee - Management Program
PDF
No ratings yet
Java Program Employee - Management Program
2 pages
Untitled document-1
PDF
No ratings yet
Untitled document-1
4 pages
Employees: Employee
PDF
No ratings yet
Employees: Employee
6 pages
Import Class Public Static Void New Double Int While: "Enter Salary: "
PDF
No ratings yet
Import Class Public Static Void New Double Int While: "Enter Salary: "
2 pages
Code For Employee Class in Java
PDF
No ratings yet
Code For Employee Class in Java
2 pages
ass3prac2
PDF
No ratings yet
ass3prac2
4 pages
11 Task Performance in Integrative Programming
PDF
No ratings yet
11 Task Performance in Integrative Programming
10 pages
JAVA ASSIGNMENT-3
PDF
No ratings yet
JAVA ASSIGNMENT-3
13 pages
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet
Bpops103 Module4
PDF
No ratings yet
Bpops103 Module4
47 pages
Floorplanning Challenges in Early Chip Planning: September 2011
PDF
No ratings yet
Floorplanning Challenges in Early Chip Planning: September 2011
7 pages
It Workshop Lab Manual: Csi Wesley Institute of Tech &SC
PDF
No ratings yet
It Workshop Lab Manual: Csi Wesley Institute of Tech &SC
82 pages
The Application of Artificial Intelligence in Project Management Research: A Review
PDF
No ratings yet
The Application of Artificial Intelligence in Project Management Research: A Review
14 pages
Android Application Components
PDF
No ratings yet
Android Application Components
4 pages
Indexing and Hashing: Solutions To Practice Exercises
PDF
No ratings yet
Indexing and Hashing: Solutions To Practice Exercises
11 pages
Avid High-Resolution Workflows Guide
PDF
No ratings yet
Avid High-Resolution Workflows Guide
144 pages
Hierarchical Inheritance With Examples in Python
PDF
No ratings yet
Hierarchical Inheritance With Examples in Python
4 pages
Set B
PDF
No ratings yet
Set B
12 pages
Instant Download Explore The Raspberry Pi in 45 Electronics Projects 3rd Edition Team IRA Bert Van Dam PDF All Chapter
PDF
No ratings yet
Instant Download Explore The Raspberry Pi in 45 Electronics Projects 3rd Edition Team IRA Bert Van Dam PDF All Chapter
54 pages
B. Voc AI and ML Syllabus
PDF
No ratings yet
B. Voc AI and ML Syllabus
2 pages
Jadhav Apoorva 14302297 (02) Cover Letter
PDF
No ratings yet
Jadhav Apoorva 14302297 (02) Cover Letter
1 page
Colour Sorting Mats A
PDF
No ratings yet
Colour Sorting Mats A
28 pages
DB (10,11,12,13,14,16,19,23)
PDF
No ratings yet
DB (10,11,12,13,14,16,19,23)
41 pages
ADD 2023: Towards Audio Deepfake Detection and Analysis in The Wild
PDF
No ratings yet
ADD 2023: Towards Audio Deepfake Detection and Analysis in The Wild
12 pages
DMR Trunking Terminal CPS ProgrammingV1.0
PDF
No ratings yet
DMR Trunking Terminal CPS ProgrammingV1.0
42 pages
Game Design and Development: Assignment 3
PDF
No ratings yet
Game Design and Development: Assignment 3
18 pages
Reverse Engineering-A General Review
PDF
No ratings yet
Reverse Engineering-A General Review
5 pages
OOP Question Paper 1
PDF
100% (1)
OOP Question Paper 1
4 pages
The Irobot® Create®2 - Raspberry Pi - Camera - Web Interface Project
PDF
No ratings yet
The Irobot® Create®2 - Raspberry Pi - Camera - Web Interface Project
44 pages
Aif c01 Demo
PDF
No ratings yet
Aif c01 Demo
27 pages
New ShowGeneralReport
PDF
No ratings yet
New ShowGeneralReport
1 page
Crafting of Web Page - Blog Through Online Platforms
PDF
No ratings yet
Crafting of Web Page - Blog Through Online Platforms
75 pages
Health Insurance Project Requirement
PDF
No ratings yet
Health Insurance Project Requirement
6 pages
1.3 Scoop On Power
PDF
No ratings yet
1.3 Scoop On Power
17 pages
MongoDB, Cloud Fund, Talend, UNIX
PDF
No ratings yet
MongoDB, Cloud Fund, Talend, UNIX
8 pages
Unit I Relational Databases
PDF
No ratings yet
Unit I Relational Databases
50 pages
First Lab Class Handouts - To Upload - 24-03-2021
PDF
No ratings yet
First Lab Class Handouts - To Upload - 24-03-2021
30 pages