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
4 pages
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
Save
Save Implementation of Java Program to Demonstrate Aggr... For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
19 views
4 pages
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
Carousel Previous
Carousel Next
Download
Save
Save Implementation of Java Program to Demonstrate Aggr... For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Implementation of Java Program to Demonstrate Aggr... For Later
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
Java Project Report On Employee Management System
PDF
100% (1)
Java Project Report On Employee Management System
16 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
Java Ass 6
PDF
No ratings yet
Java Ass 6
8 pages
OOP Answer-Key
PDF
No ratings yet
OOP Answer-Key
15 pages
Implementation of Java Program To Demonstrate Exception Handling
PDF
No ratings yet
Implementation of Java Program To Demonstrate Exception Handling
6 pages
Java PGM 10-18
PDF
No ratings yet
Java PGM 10-18
24 pages
Salary C# Program
PDF
No ratings yet
Salary C# Program
3 pages
Java Output
PDF
No ratings yet
Java Output
8 pages
Java Tasks Report
PDF
No ratings yet
Java Tasks Report
4 pages
Public Class Exercise14
PDF
No ratings yet
Public Class Exercise14
5 pages
Oop Reference Manual - Final
PDF
No ratings yet
Oop Reference Manual - Final
75 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
Program On This Keyword
PDF
No ratings yet
Program On This Keyword
2 pages
PF Lab 9
PDF
No ratings yet
PF Lab 9
5 pages
APT1030 Assignment2
PDF
No ratings yet
APT1030 Assignment2
3 pages
Personal Finance Tracker
PDF
No ratings yet
Personal Finance Tracker
5 pages
Assignment 1
PDF
No ratings yet
Assignment 1
7 pages
Prova Av2
PDF
No ratings yet
Prova Av2
11 pages
Salary Component
PDF
No ratings yet
Salary Component
2 pages
PP 2 Brian Sankey
PDF
No ratings yet
PP 2 Brian Sankey
4 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
PGM 3
PDF
No ratings yet
PGM 3
1 page
C#Lab5 7
PDF
No ratings yet
C#Lab5 7
8 pages
Assignment - 3
PDF
No ratings yet
Assignment - 3
5 pages
Class Employee
PDF
No ratings yet
Class Employee
2 pages
Solution Lab Mini Project Java
PDF
No ratings yet
Solution Lab Mini Project Java
2 pages
Employee Payroll System
PDF
No ratings yet
Employee Payroll System
2 pages
Assignments Pooja Gaikwad
PDF
No ratings yet
Assignments Pooja Gaikwad
23 pages
Computer Project Class 12th
PDF
No ratings yet
Computer Project Class 12th
91 pages
Esaimen Ooop
PDF
No ratings yet
Esaimen Ooop
9 pages
Exp (4) - 2
PDF
No ratings yet
Exp (4) - 2
9 pages
Midterm Exam Set Two II
PDF
No ratings yet
Midterm Exam Set Two II
2 pages
Oop 3 Fa20-Be-012
PDF
No ratings yet
Oop 3 Fa20-Be-012
19 pages
Lucrarea de Laborator Nr. 3: Raport La
PDF
No ratings yet
Lucrarea de Laborator Nr. 3: Raport La
12 pages
Karthi
PDF
No ratings yet
Karthi
5 pages
DCIT 201 Assignment
PDF
No ratings yet
DCIT 201 Assignment
18 pages
Lab Polymorphism
PDF
No ratings yet
Lab Polymorphism
6 pages
ASS3
PDF
No ratings yet
ASS3
11 pages
2.2 Employee
PDF
No ratings yet
2.2 Employee
1 page
المستند
PDF
No ratings yet
المستند
3 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
Payroll System Final
PDF
No ratings yet
Payroll System Final
7 pages
Koustubh Javapraticalassignment1
PDF
No ratings yet
Koustubh Javapraticalassignment1
14 pages
Renzie
PDF
No ratings yet
Renzie
2 pages
Assignment# 2
PDF
No ratings yet
Assignment# 2
5 pages
Java 2
PDF
No ratings yet
Java 2
4 pages
CODER
PDF
No ratings yet
CODER
14 pages
Person
PDF
No ratings yet
Person
3 pages
Lab 7
PDF
No ratings yet
Lab 7
29 pages
Ducati Monster '01 Owner's Manual General
PDF
100% (1)
Ducati Monster '01 Owner's Manual General
81 pages
Chapter-Seven: Object-Oriented Implementation
PDF
No ratings yet
Chapter-Seven: Object-Oriented Implementation
23 pages
Java
PDF
No ratings yet
Java
5 pages
Programmed Assessment
PDF
No ratings yet
Programmed Assessment
6 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
Neelu
PDF
No ratings yet
Neelu
14 pages
Question # 1: Assignment # 1 (OOP C#)
PDF
No ratings yet
Question # 1: Assignment # 1 (OOP C#)
16 pages
OOP Assignment 02
PDF
No ratings yet
OOP Assignment 02
17 pages
Java 3 & 4
PDF
0% (1)
Java 3 & 4
50 pages
Employee Oop Example
PDF
No ratings yet
Employee Oop Example
5 pages
Assignment 01
PDF
No ratings yet
Assignment 01
7 pages
Tally and Accounting Course Notes
PDF
No ratings yet
Tally and Accounting Course Notes
35 pages
Nafco AFFF C-6
PDF
No ratings yet
Nafco AFFF C-6
4 pages
Chapter 7 Training: True/False Questions
PDF
No ratings yet
Chapter 7 Training: True/False Questions
29 pages
Breeds of Poultry Species
PDF
100% (1)
Breeds of Poultry Species
5 pages
Principles of Accounting (ACC-1101)
PDF
No ratings yet
Principles of Accounting (ACC-1101)
4 pages
Ifrs 7 Financial Instruments Disclosures
PDF
No ratings yet
Ifrs 7 Financial Instruments Disclosures
70 pages
Random-Access Memory
PDF
No ratings yet
Random-Access Memory
19 pages
Mep 2020 Nov
PDF
No ratings yet
Mep 2020 Nov
1 page
PWD Rej.
PDF
No ratings yet
PWD Rej.
52 pages
Massachusetts Institute of Technology: Case Study Case Study
PDF
No ratings yet
Massachusetts Institute of Technology: Case Study Case Study
3 pages
Iso 23910 2007
PDF
No ratings yet
Iso 23910 2007
8 pages
2.1 Definition of Small Business
PDF
No ratings yet
2.1 Definition of Small Business
45 pages
01 Architecture
PDF
No ratings yet
01 Architecture
22 pages
PDF Apo Fruits Corporation V Land Bank of The Philippines - Compress
PDF
No ratings yet
PDF Apo Fruits Corporation V Land Bank of The Philippines - Compress
4 pages
Answer Bigamy
PDF
No ratings yet
Answer Bigamy
3 pages
Galle - Makumbura (Normal Day)
PDF
No ratings yet
Galle - Makumbura (Normal Day)
2 pages
Compiler Design 10
PDF
No ratings yet
Compiler Design 10
5 pages
Week 6 Tutorial T&D With Answers
PDF
No ratings yet
Week 6 Tutorial T&D With Answers
4 pages
Emergency
PDF
No ratings yet
Emergency
5 pages
Smart Materials Final
PDF
No ratings yet
Smart Materials Final
4 pages
M55 LE1 Review Handout
PDF
No ratings yet
M55 LE1 Review Handout
33 pages
21fs2rlx LG
PDF
No ratings yet
21fs2rlx LG
30 pages
ISSN 1411 - 5247 Perancangan Produk Tempat Tisu Multifungsi Dengan Menggunakan Quality Function Deployment (QFD)
PDF
No ratings yet
ISSN 1411 - 5247 Perancangan Produk Tempat Tisu Multifungsi Dengan Menggunakan Quality Function Deployment (QFD)
9 pages
Excercise Process Analysis
PDF
No ratings yet
Excercise Process Analysis
8 pages
Topacio v. Ong, G.R. No. 179895, December 18, 2008
PDF
No ratings yet
Topacio v. Ong, G.R. No. 179895, December 18, 2008
13 pages
Danish Ayub
PDF
No ratings yet
Danish Ayub
3 pages
Alfredo Medina - Resume - June 09
PDF
No ratings yet
Alfredo Medina - Resume - June 09
3 pages
Fesco Online Billl
PDF
No ratings yet
Fesco Online Billl
1 page
Construction Weekly Progress Report
PDF
No ratings yet
Construction Weekly Progress Report
1 page
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet