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
We take content rights seriously. If you suspect this is your content,
claim it here
.
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
We take content rights seriously. If you suspect this is your content,
claim it here
.
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
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
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
Matched To The Pack - Layla Sparks
PDF
No ratings yet
Matched To The Pack - Layla Sparks
239 pages
CC Case Brief
PDF
No ratings yet
CC Case Brief
35 pages
Cyber Security Presentation From Barclays
PDF
No ratings yet
Cyber Security Presentation From Barclays
13 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
assignment1
PDF
No ratings yet
assignment1
7 pages
Koustubh Javapraticalassignment1
PDF
No ratings yet
Koustubh Javapraticalassignment1
14 pages
Salary c# Program
PDF
No ratings yet
Salary c# Program
3 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
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
OOP Assignment 02
PDF
No ratings yet
OOP Assignment 02
17 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
Payroll System Final
PDF
No ratings yet
Payroll System Final
7 pages
Class Employee
PDF
No ratings yet
Class Employee
2 pages
Midterm Exam Set Two II
PDF
No ratings yet
Midterm Exam Set Two II
2 pages
APT1030_assignment2
PDF
No ratings yet
APT1030_assignment2
3 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
C#Lab5 7
PDF
No ratings yet
C#Lab5 7
8 pages
SalaryComponent
PDF
No ratings yet
SalaryComponent
2 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
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet
Introduction To Advertisement: A Dissertation
PDF
No ratings yet
Introduction To Advertisement: A Dissertation
35 pages
Indicators (For Steam Engines)
PDF
0% (1)
Indicators (For Steam Engines)
67 pages
A Pictures V (HRTH: Topics in Autism
PDF
No ratings yet
A Pictures V (HRTH: Topics in Autism
172 pages
Procedure Fiat vs Usdt 2025
PDF
No ratings yet
Procedure Fiat vs Usdt 2025
2 pages
Devine Et Al-2014-Child Development
PDF
No ratings yet
Devine Et Al-2014-Child Development
18 pages
ourlog_4765
PDF
No ratings yet
ourlog_4765
5 pages
The Quantity Theory of Money
PDF
No ratings yet
The Quantity Theory of Money
30 pages
AWS Cloud Basics Concept
PDF
100% (1)
AWS Cloud Basics Concept
19 pages
Central OBC Certificate - OBC240704046037
PDF
No ratings yet
Central OBC Certificate - OBC240704046037
1 page
Owais_Khan(CV)_Updated-
PDF
No ratings yet
Owais_Khan(CV)_Updated-
6 pages
Asante Ic3624-Ic3648 Um
PDF
No ratings yet
Asante Ic3624-Ic3648 Um
145 pages
G. R. Owst Preaching in Medieval England An Introduction To Sermon Manuscripts of The Period c.1350-1450 Cambridge Library Collection - History PDF
PDF
67% (3)
G. R. Owst Preaching in Medieval England An Introduction To Sermon Manuscripts of The Period c.1350-1450 Cambridge Library Collection - History PDF
406 pages
Project Proposal - Uniporme
PDF
100% (1)
Project Proposal - Uniporme
2 pages
Element - 111 - 128-Petrol Station BOQ
PDF
No ratings yet
Element - 111 - 128-Petrol Station BOQ
6 pages
GRADE-5-GEMELINA-TEST REASULT-Q3-SY2023-2024
PDF
No ratings yet
GRADE-5-GEMELINA-TEST REASULT-Q3-SY2023-2024
2 pages
Project Work
PDF
80% (10)
Project Work
9 pages
Skills: Civil Engineer July 2012-Present
PDF
No ratings yet
Skills: Civil Engineer July 2012-Present
2 pages
Mercieri - 2019.03.19 - Complaint
PDF
No ratings yet
Mercieri - 2019.03.19 - Complaint
25 pages
Temp - CFA Paper 1
PDF
No ratings yet
Temp - CFA Paper 1
9 pages
Brillantes (2004)
PDF
No ratings yet
Brillantes (2004)
27 pages
Rujukan 2023
PDF
No ratings yet
Rujukan 2023
80 pages
Web Cont
PDF
No ratings yet
Web Cont
20 pages
Download ebooks file Introduction to Dislocations Fourth Edition Derek Hull all chapters
PDF
No ratings yet
Download ebooks file Introduction to Dislocations Fourth Edition Derek Hull all chapters
51 pages
Dawn at Puri Analysis
PDF
33% (3)
Dawn at Puri Analysis
2 pages
KTP 8 Klass 20-21 Uch God Avtovosstanovlenie
PDF
No ratings yet
KTP 8 Klass 20-21 Uch God Avtovosstanovlenie
7 pages
CLTD
PDF
No ratings yet
CLTD
5 pages
DLL_ENGLISH-1_Q3_W1
PDF
No ratings yet
DLL_ENGLISH-1_Q3_W1
6 pages