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)
7 views
Implementation of Java Program To Pass Arguments To A Method and Return Value
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 Pass Arguments t... For Later
Download
Save
Save Implementation of Java Program to Pass Arguments t... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
7 views
Implementation of Java Program To Pass Arguments To A Method and Return Value
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 Pass Arguments t... For Later
Carousel Previous
Carousel Next
Download
Save
Save Implementation of Java Program to Pass Arguments t... For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 8
Search
Fullscreen
IMPLEMENTATION OF JAVA PROGRAM TO PASS ARGUMENTS TO A
METHOD AND RETURN VALUE
PROGRAM CODE:
class Salary {
double m_salary;
double other;
Salary(double m, double o) {
this.m_salary = m;
this.other = o;
}
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;
}
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;
}
double savings_earned() {
return tsalary - twages;
}
}
public class Exp {
public static void main(String[] args) {
Salary sal = new Salary(32000, 5000);
Wages wag = new Wages(20000, 3000, 5000);
Savings sav = new Savings(sal.m_salary + sal.other, wag.home_wages +
wag.repair_charges + wag.medicinal_wages);
double ts = sal.totalsalary();
double tw = wag.totalwages();
double se = sav.savings_earned();
System.out.println("TOTAL SALARY: " + ts);
System.out.println("TOTAL WAGES: " + tw);
System.out.println("TOTAL SAVINGS: " + se);
}
}
OUTPUT:
IMPLEMENTATION OF JAVA PROGRAM TO PASS ARGUMENTS TO A
METHOD AND RETURN VALUE
PROGRAM CODE:
class Salary {
double m_salary;
double other;
Salary(double m, double o) {
this.m_salary = m;
this.other = o;
}
double totalsalary() {
return m_salary + other;
}
static double totalSalaryFromArray(Salary[] salaries) {
double total = 0;
for (Salary salary : salaries) {
total += salary.totalsalary();
}
return total;
}
}
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;
}
double totalwages() {
return home_wages + repair_charges + medicinal_wages;
}
static double totalWagesFromArray(Wages[] wagesArray) {
double total = 0;
for (Wages wages : wagesArray) {
total += wages.totalwages();
}
return total;
}
}
class Savings {
double tsalary;
double twages;
Savings(double sala, double wage) {
this.tsalary = sala;
this.twages = wage;
}
double savingsEarned() {
return tsalary - twages;
}
static Savings calculateSavings(Salary[] salaries, Wages[] wagesArray) {
double totalSalary = Salary.totalSalaryFromArray(salaries);
double totalWages = Wages.totalWagesFromArray(wagesArray);
return new Savings(totalSalary, totalWages);
}
}
class ExpenseTracker {
double totalExpenses = 0;
void addExpense(double amount) {
totalExpenses += amount;
}
double getTotalExpenses() {
return totalExpenses;
}
}
public class Exp1 {
public static void main(String[] args) {
Salary[] salaries = {
new Salary(32000, 5000),
new Salary(35000, 7000)
};
Wages[] wagesArray = {
new Wages(20000, 3000, 5000),
new Wages(15000, 2000, 3000)
};
Savings sav = Savings.calculateSavings(salaries, wagesArray);
double ts = Salary.totalSalaryFromArray(salaries);
double tw = Wages.totalWagesFromArray(wagesArray);
double se = sav.savingsEarned();
ExpenseTracker expenseTracker = new ExpenseTracker();
expenseTracker.addExpense(1500);
expenseTracker.addExpense(300);
double totalExpenses = expenseTracker.getTotalExpenses();
System.out.println("TOTAL SALARY: " + ts);
System.out.println("TOTAL WAGES: " + tw);
System.out.println("TOTAL SAVINGS: " + se);
System.out.println("TOTAL EXPENSES: " + totalExpenses);
}
}
OUTPUT:
You might also like
SHARIPOV
PDF
No ratings yet
SHARIPOV
2 pages
MD Imran Welder 2200
PDF
100% (1)
MD Imran Welder 2200
1 page
Polymorphism, Relations
PDF
50% (2)
Polymorphism, Relations
46 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 Demonstrate Aggregation and Composition
PDF
No ratings yet
Implementation of Java Program To Demonstrate Aggregation and Composition
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
Implementation of Java Program To Demonstrate Exception Handling
PDF
No ratings yet
Implementation of Java Program To Demonstrate Exception Handling
6 pages
Java
PDF
No ratings yet
Java
5 pages
Koustubh Javapraticalassignment1
PDF
No ratings yet
Koustubh Javapraticalassignment1
14 pages
OOP_Answer-Key
PDF
No ratings yet
OOP_Answer-Key
15 pages
Lab Polymorphism
PDF
No ratings yet
Lab Polymorphism
6 pages
Assignment# 2
PDF
No ratings yet
Assignment# 2
5 pages
assignment1
PDF
No ratings yet
assignment1
7 pages
Oop 3 Fa20-Be-012
PDF
No ratings yet
Oop 3 Fa20-Be-012
19 pages
PGM 3
PDF
No ratings yet
PGM 3
1 page
OOP Assignment 02
PDF
No ratings yet
OOP Assignment 02
17 pages
Prova Av2
PDF
No ratings yet
Prova Av2
11 pages
Assignment - 3
PDF
No ratings yet
Assignment - 3
5 pages
Neelu
PDF
No ratings yet
Neelu
14 pages
EXP (4)-2
PDF
No ratings yet
EXP (4)-2
9 pages
Person
PDF
No ratings yet
Person
3 pages
Lab 4
PDF
0% (1)
Lab 4
13 pages
Programming Notes
PDF
No ratings yet
Programming Notes
4 pages
Anurag Tiwari Mca.10029.24 Assignment 9
PDF
No ratings yet
Anurag Tiwari Mca.10029.24 Assignment 9
7 pages
NLP I LEVEL 2021-1 INITIAL COMPLETED - Jiancarlos Anton Vasquez
PDF
No ratings yet
NLP I LEVEL 2021-1 INITIAL COMPLETED - Jiancarlos Anton Vasquez
14 pages
Employee Oop Example
PDF
No ratings yet
Employee Oop Example
5 pages
MiU Technical interview prep
PDF
No ratings yet
MiU Technical interview prep
35 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
Java 3 & 4
PDF
0% (1)
Java 3 & 4
50 pages
Assignment 01
PDF
No ratings yet
Assignment 01
7 pages
Java_Tasks_Report (1)
PDF
No ratings yet
Java_Tasks_Report (1)
4 pages
Assignments Pooja Gaikwad
PDF
No ratings yet
Assignments Pooja Gaikwad
23 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
Java Output
PDF
No ratings yet
Java Output
8 pages
JAVA ASSIGNMENT-3
PDF
No ratings yet
JAVA ASSIGNMENT-3
13 pages
Java pgm 10-18
PDF
No ratings yet
Java pgm 10-18
24 pages
Exp 07
PDF
No ratings yet
Exp 07
31 pages
CODER
PDF
No ratings yet
CODER
14 pages
Employees: Employee
PDF
No ratings yet
Employees: Employee
6 pages
Salary c# Program
PDF
No ratings yet
Salary c# Program
3 pages
Lab 7
PDF
No ratings yet
Lab 7
29 pages
Question # 1: Assignment # 1 (OOP C#)
PDF
No ratings yet
Question # 1: Assignment # 1 (OOP C#)
16 pages
Lab 8
PDF
No ratings yet
Lab 8
16 pages
ass3prac2
PDF
No ratings yet
ass3prac2
4 pages
EXPT 7B.docx (4)
PDF
No ratings yet
EXPT 7B.docx (4)
11 pages
Solution Lab Mini Project Java
PDF
No ratings yet
Solution Lab Mini Project Java
2 pages
Personal Finance Tracker
PDF
No ratings yet
Personal Finance Tracker
5 pages
Computer Project Class 12th
PDF
No ratings yet
Computer Project Class 12th
91 pages
Java Lab Evaluation
PDF
No ratings yet
Java Lab Evaluation
2 pages
23011103044_SandhyaP_Exercise2
PDF
No ratings yet
23011103044_SandhyaP_Exercise2
9 pages
Renzie
PDF
No ratings yet
Renzie
2 pages
PF lab 9
PDF
No ratings yet
PF lab 9
5 pages
assignment34
PDF
No ratings yet
assignment34
7 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 lab1
PDF
No ratings yet
java lab1
10 pages
My_Handwritten_Questions_To_Practtice_Coding
PDF
No ratings yet
My_Handwritten_Questions_To_Practtice_Coding
3 pages
Name1
PDF
No ratings yet
Name1
43 pages
Ass Java
PDF
No ratings yet
Ass Java
6 pages
Chapter-Seven: Object-Oriented Implementation
PDF
No ratings yet
Chapter-Seven: Object-Oriented Implementation
23 pages
Gsis Salary Loan
PDF
No ratings yet
Gsis Salary Loan
2 pages
5. OOP
PDF
No ratings yet
5. OOP
5 pages
Software Design Simplified
From Everand
Software Design Simplified
Liviu Catalin Dorobantu
No ratings yet
Essentials of HRM
PDF
No ratings yet
Essentials of HRM
8 pages
Unorganised Sector
PDF
No ratings yet
Unorganised Sector
13 pages
Wordlist BusinessPartner A2+
PDF
No ratings yet
Wordlist BusinessPartner A2+
30 pages
Harikrishna P-Offer Letter 1488
PDF
No ratings yet
Harikrishna P-Offer Letter 1488
4 pages
Bibliografie
PDF
No ratings yet
Bibliografie
5 pages
Career Plan
PDF
No ratings yet
Career Plan
13 pages
BIR Rulings
PDF
No ratings yet
BIR Rulings
4 pages
Strategic Management Report On Askari Bank
PDF
100% (1)
Strategic Management Report On Askari Bank
36 pages
Updated Resume 2024
PDF
No ratings yet
Updated Resume 2024
2 pages
Hillrange Pension Company
PDF
No ratings yet
Hillrange Pension Company
5 pages
Module 4 - Managerial Communication
PDF
No ratings yet
Module 4 - Managerial Communication
66 pages
Workers Participation in Management
PDF
No ratings yet
Workers Participation in Management
12 pages
Jesselton Waterfront Development: Modernizing Kota Kinabalu City
PDF
No ratings yet
Jesselton Waterfront Development: Modernizing Kota Kinabalu City
8 pages
Ch#2
PDF
No ratings yet
Ch#2
32 pages
Production Repairs Engineer
PDF
No ratings yet
Production Repairs Engineer
3 pages
Managemtproject 141127081921 Conversion Gate01 PDF
PDF
No ratings yet
Managemtproject 141127081921 Conversion Gate01 PDF
22 pages
Worker Care Spectrum-1
PDF
No ratings yet
Worker Care Spectrum-1
21 pages
Shaheed Bhagat Singh (Eve.) College: Certificate To Be Submitted by The Pensioner
PDF
No ratings yet
Shaheed Bhagat Singh (Eve.) College: Certificate To Be Submitted by The Pensioner
2 pages
April 2011 Chemical Engineers Licensure Examination Room Assignments
PDF
No ratings yet
April 2011 Chemical Engineers Licensure Examination Room Assignments
16 pages
FNPDC Project, Yanbu, KSA Daily HSE Preparedness Checklist: Coverage Area: Date: Brief Description of Activities
PDF
100% (1)
FNPDC Project, Yanbu, KSA Daily HSE Preparedness Checklist: Coverage Area: Date: Brief Description of Activities
2 pages
Form No. 32: Medical Examination Results Therefore If Declared Unfit For Work
PDF
No ratings yet
Form No. 32: Medical Examination Results Therefore If Declared Unfit For Work
1 page
Kapai New Zealand: Eat Your Greens!: Figure 1: Kapai Owners, James Irvine and Justin Lester
PDF
No ratings yet
Kapai New Zealand: Eat Your Greens!: Figure 1: Kapai Owners, James Irvine and Justin Lester
17 pages
Chapter 1 and 2
PDF
100% (1)
Chapter 1 and 2
77 pages
Models of Organizational Behavior-Brief
PDF
No ratings yet
Models of Organizational Behavior-Brief
15 pages
Payroll Brgy. Officials May 2021
PDF
No ratings yet
Payroll Brgy. Officials May 2021
1 page
Jeanette Garnier Resume
PDF
No ratings yet
Jeanette Garnier Resume
1 page
Boilermaker Resume Australia
PDF
100% (1)
Boilermaker Resume Australia
4 pages
Meanings and Dimensions of Culture
PDF
No ratings yet
Meanings and Dimensions of Culture
40 pages