Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Edit: I need help on making minimum, maximum, and average for two variables. Full instructions: Include getter and setter methods for each instance value. Include

Edit: I need help on making minimum, maximum, and average for two variables.

Full instructions:

  1. Include getter and setter methods for each instance value.
  2. Include a toString() method that will return a String representing the values of a given instance of the object.
  3. This project should have no fewer than five instances of your object. Your program design needs be based on an array of objects. Use the demo program in this lesson as a model for how to create and process an array of objects.
  4. Determine the minimum and maximum values key data columns. (Recall the Integer class constants MIN_VALUE and MAX_VALUE. The Double class also has class constants of the same name.)
  5. Calculate the average for key data columns.
  6. Output needs to be neatly organized and user friendly.

Please help me...

I want my program to look like this expected output (only on min, max, avg part):

image text in transcribed

My Output:

image text in transcribed

I need help on coding "Minimum, Maximum, Average" portion (like shown in expected output) on "Wins" and "Games" in my code.

There are three different output sections (that I need):

1) the rows of data

2) the minimum and maximum values,

3) the averages.

My code is down below:

import java.util.Calendar; public class SoccerPlayerV7 { private String playerName; private int wins; private int gamesPlayed; private int debutYear; int playingYears; double winRate; //constructor for SoccerPlayerV7 public SoccerPlayerV7(int debutYear1, int gamesPlayed1, int wins1, String playerName1) { playerName = playerName1; debutYear = debutYear1; gamesPlayed = gamesPlayed1; wins = wins1; //call the methods playingYears = yearsSinceDebut(debutYear); winRate = avgWinRate(wins, gamesPlayed); } //print title public static void printTitle() { System.out.printf("%50s%n%n", "Statistic of Soccer Players"); System.out.printf("%5s", " Player Name"); System.out.printf("%20s", "Playing Years"); System.out.printf("%9s","Debut" ); System.out.printf("%9s", "Games"); System.out.printf("%9s", "Wins"); System.out.printf("%10s%n", "Winrate"); System.out.println("====================================================================="); } //create heading public void printData() { //print statistics System.out.printf("%14s", playerName); System.out.printf("%13d", playingYears); System.out.printf("%13d", debutYear); System.out.printf("%9d", gamesPlayed); System.out.printf("%9d", wins); System.out.printf("%10.2f%n", winRate); } //calculate years since debut public int yearsSinceDebut(int debutYear) { // year is stored as a static member int year = Calendar.getInstance().get(Calendar.YEAR); int playingYear = year - debutYear; return playingYear; } //calculate winrate public double avgWinRate(int wins, int gamesPlayed) { return (double)wins / gamesPlayed; } }

public class SoccerPlayerV7Tester { //main method public static void main(String[] args) { //construct SoccerPlayerV7 SoccerPlayerV7 SoccerPlayer1 = new SoccerPlayerV7 (2011, 185, 105, " Son, Heungmin"); SoccerPlayerV7 SoccerPlayer2 = new SoccerPlayerV7 (2009, 196, 132, "Kane, Harry "); SoccerPlayerV7 SoccerPlayer3 = new SoccerPlayerV7 (2010, 175, 95, " Agger, Daniel"); //heading SoccerPlayerV7.printTitle(); //print out statistics SoccerPlayer1.printData(); SoccerPlayer2.printData(); SoccerPlayer3.printData(); } }

Expected Output: When the program runs correctly, the output will resemble the following screen shot. Your output will differ depending on the project and object you choose. Name Time 1 (hrs) Time Trials Time 2 Time Difference (hrs) (hrs) Difference in Minutes Tanya Miguel Neeti 2.50 1.25 12.30 4.50 5.60 16.75 2.00 4.35 4.45 120 261 266 Minimum: Maximum: Average : 2.00 4.45 3.60 120 266 215.67 Statistic of Soccer Players Player Name Playing Years Debut Games Wins Winrate 10 Son, Heungmin Kane, Harry Agger, Daniel 12 11 2011 2009 2010 185 196 175 105 132 95 0.57 0.67 0.54

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions