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 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
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 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
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
Computer Project Class 12th
PDF
No ratings yet
Computer Project Class 12th
91 pages
Java Project Report On Employee Management System
PDF
100% (1)
Java Project Report On Employee Management System
16 pages
Love Me Whole - Nicky James
PDF
No ratings yet
Love Me Whole - Nicky James
340 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
Java 3 & 4
PDF
0% (1)
Java 3 & 4
50 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
Personal Finance Tracker
PDF
No ratings yet
Personal Finance Tracker
5 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
Prova Av2
PDF
No ratings yet
Prova Av2
11 pages
Oop 3 Fa20-Be-012
PDF
No ratings yet
Oop 3 Fa20-Be-012
19 pages
DCIT 201 Assignment
PDF
No ratings yet
DCIT 201 Assignment
18 pages
Ahmedabad Court Ruling On Notice period
PDF
No ratings yet
Ahmedabad Court Ruling On Notice period
11 pages
Assignments Pooja Gaikwad
PDF
No ratings yet
Assignments Pooja Gaikwad
23 pages
C#Lab5 7
PDF
No ratings yet
C#Lab5 7
8 pages
Lucrarea de Laborator Nr. 3: Raport La
PDF
No ratings yet
Lucrarea de Laborator Nr. 3: Raport La
12 pages
Lab 7
PDF
No ratings yet
Lab 7
29 pages
Esaimen Ooop
PDF
No ratings yet
Esaimen Ooop
9 pages
Lab Polymorphism
PDF
No ratings yet
Lab Polymorphism
6 pages
public class Exercise14
PDF
No ratings yet
public class Exercise14
5 pages
Java_Tasks_Report (1)
PDF
No ratings yet
Java_Tasks_Report (1)
4 pages
PF lab 9
PDF
No ratings yet
PF lab 9
5 pages
Java
PDF
No ratings yet
Java
5 pages
OOP_Answer-Key
PDF
No ratings yet
OOP_Answer-Key
15 pages
Salary c# Program
PDF
No ratings yet
Salary c# Program
3 pages
Java Output
PDF
No ratings yet
Java Output
8 pages
PP 2 Brian Sankey
PDF
No ratings yet
PP 2 Brian Sankey
4 pages
EXP (4)-2
PDF
No ratings yet
EXP (4)-2
9 pages
Untitled document-1
PDF
No ratings yet
Untitled document-1
4 pages
karthi
PDF
No ratings yet
karthi
5 pages
assignment1
PDF
No ratings yet
assignment1
7 pages
OOP Assignment 02
PDF
No ratings yet
OOP Assignment 02
17 pages
Chapter-Seven: Object-Oriented Implementation
PDF
No ratings yet
Chapter-Seven: Object-Oriented Implementation
23 pages
APT1030_assignment2
PDF
No ratings yet
APT1030_assignment2
3 pages
CODER
PDF
No ratings yet
CODER
14 pages
Neelu
PDF
No ratings yet
Neelu
14 pages
ASS3
PDF
No ratings yet
ASS3
11 pages
program on this keyword
PDF
No ratings yet
program on this keyword
2 pages
Person
PDF
No ratings yet
Person
3 pages
SalaryComponent
PDF
No ratings yet
SalaryComponent
2 pages
Class Employee
PDF
No ratings yet
Class Employee
2 pages
Assignment# 2
PDF
No ratings yet
Assignment# 2
5 pages
Solution Lab Mini Project Java
PDF
No ratings yet
Solution Lab Mini Project Java
2 pages
java ass 6
PDF
No ratings yet
java ass 6
8 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
Question # 1: Assignment # 1 (OOP C#)
PDF
No ratings yet
Question # 1: Assignment # 1 (OOP C#)
16 pages
PGM 3
PDF
No ratings yet
PGM 3
1 page
Koustubh Javapraticalassignment1
PDF
No ratings yet
Koustubh Javapraticalassignment1
14 pages
Midterm Exam Set Two II
PDF
No ratings yet
Midterm Exam Set Two II
2 pages
Assignment - 3
PDF
No ratings yet
Assignment - 3
5 pages
Myths & Legends
PDF
No ratings yet
Myths & Legends
4 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
Payroll System Final
PDF
No ratings yet
Payroll System Final
7 pages
programmed assessment
PDF
No ratings yet
programmed assessment
6 pages
Soft Heart
PDF
No ratings yet
Soft Heart
10 pages
Renzie
PDF
No ratings yet
Renzie
2 pages
Java Program Employee - Management Program
PDF
No ratings yet
Java Program Employee - Management Program
2 pages
Employee Oop Example
PDF
No ratings yet
Employee Oop Example
5 pages
2.2 Employee
PDF
No ratings yet
2.2 Employee
1 page
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
Nokia AirScale Base Station
PDF
100% (2)
Nokia AirScale Base Station
5 pages
Assignment 01
PDF
No ratings yet
Assignment 01
7 pages
المستند
PDF
No ratings yet
المستند
3 pages
Ridhi-Checkmate (1)
PDF
No ratings yet
Ridhi-Checkmate (1)
43 pages
Mita Shree 69
PDF
No ratings yet
Mita Shree 69
25 pages
Week 1 - Lecture Note - With Solution
PDF
No ratings yet
Week 1 - Lecture Note - With Solution
33 pages
La Felicita Polo Estate
PDF
No ratings yet
La Felicita Polo Estate
4 pages
Theories of Poverty: A Critical Review
PDF
No ratings yet
Theories of Poverty: A Critical Review
8 pages
Mba Course Curriculum Puc
PDF
No ratings yet
Mba Course Curriculum Puc
18 pages
GHG-TNI-01 Rev.08 Procedure For The Verification of GHG Statements
PDF
No ratings yet
GHG-TNI-01 Rev.08 Procedure For The Verification of GHG Statements
60 pages
NEPAL ICE Promotion
PDF
No ratings yet
NEPAL ICE Promotion
12 pages
jac
PDF
No ratings yet
jac
8 pages
MANTRA-MONSOON PREPRADNESS PLAN
PDF
No ratings yet
MANTRA-MONSOON PREPRADNESS PLAN
12 pages
Letter of Complaint (Zadania-Seminarky - SK)
PDF
No ratings yet
Letter of Complaint (Zadania-Seminarky - SK)
2 pages
20120223100226chapter 3 IML 601 CL2 PDF
PDF
No ratings yet
20120223100226chapter 3 IML 601 CL2 PDF
20 pages
Spanish Homework Packet
PDF
100% (1)
Spanish Homework Packet
4 pages
03 SPRECON Engineering Center Software Modules
PDF
No ratings yet
03 SPRECON Engineering Center Software Modules
9 pages
Toxicologie HF
PDF
No ratings yet
Toxicologie HF
7 pages
A Mobile Distributed System For Personal Security
PDF
No ratings yet
A Mobile Distributed System For Personal Security
5 pages
Datastage On Ibm Cloud Pak For Data
PDF
No ratings yet
Datastage On Ibm Cloud Pak For Data
6 pages
Penyuluhan Kesehatan Tradisional
PDF
No ratings yet
Penyuluhan Kesehatan Tradisional
6 pages
Ohsm Plan Assessment Report
PDF
No ratings yet
Ohsm Plan Assessment Report
17 pages
Letter of Rec Hamilton
PDF
No ratings yet
Letter of Rec Hamilton
2 pages
Incisive Verification Ip For The Arm Amba Protocol Family: Capabilities Key Features
PDF
No ratings yet
Incisive Verification Ip For The Arm Amba Protocol Family: Capabilities Key Features
4 pages
Textual Evidence
PDF
No ratings yet
Textual Evidence
2 pages
MATH 1052 - Engineering Mathematics SOCS
PDF
No ratings yet
MATH 1052 - Engineering Mathematics SOCS
3 pages
Handling Suspicious Items and Packages in Hotels
PDF
No ratings yet
Handling Suspicious Items and Packages in Hotels
3 pages
Activity 2: Assignment Content
PDF
No ratings yet
Activity 2: Assignment Content
2 pages
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet