Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Adding amount of salary of 5 arrays of player objects? Main: System. out .print( Enter player's salary: ); double salary = input.nextDouble(); // user
Adding amount of salary of 5 arrays of player objects?
Main:
System.out.print("Enter player's salary: "); double salary = input.nextDouble(); // user enters player's salary (user is creating each individual player object here into array slots)
Team class:
double sum; //the total sum of 5 player's salary under a team
Player class:
private double salary; //salary of an individual Player
public void setSalary(double sal) { salary = sal; }
and
public double getSalary() { return salary; }
How would I create the method to add the sum of each Player's salary from the Player's class into the variable sum in the Team class? (like using a for loop in a mutator or something?)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started