Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i've added all necessary code + files needed to test, must output to file and to monitor, crucial that both are done. please refrain from

i've added all necessary code + files needed to test, must output to file and to monitor, crucial that both are done. please refrain from using solutions already available on here

You are to design a class called Team with the following members : (Use the template provided to get started)

Fields :

  • teamName
  • teamWins
  • teamLosses
  • winPercentage

Constructors:

  • default
  • parenthesized
  • Copy

Mutators:

  • setTeamName()
  • setTeamWins()
  • setTeamLosses()

Accessors:

  • getTeamName()
  • getTeamWins()
  • getTeamLosses()

And

  • toString(): format team name Wins = 45 Losses = 45 Winning Percentage = 50%

  • getWinPercentage(): To calculate the winPercentage using following the formula is: teamWins / (teamWins + teamLosses) Note: Use casting to prevent integer division.

Create a driver class named TestTeams to test the Team class with the following methods:

  • main(): use the template provided and complete the code.
  • readData(): To open a file and read the data and store them in the list
  • openFile(): To prompt user for a file name open and verify it is valid and has data and return it to the caller
  • printTable: To prompt user for an output file and print the win percentage of each team to the file and monitor.

Input file format/organization: number of wins number of losses team name

Sample file:

13 3 Ravens 7 9 Los Angeles Dodgers 8 8 New York Yankees 

output file format/organization:

Team Average Label Ravens 81.25 Winning Season Los Angeles Dodgers 43.75 Losing Season New York Yankees 50.00 winning Season 

The input is: input.txt out.txt

import java.util.Scanner; import java.io.*

public class TestTeams {// TestTeams.java file // TODO: readData(): To open a file and read the data and store them in the list // openFile(): To prompt user for a file name open and verify it is valid and has data and return it to the caller // printTable: To prompt user for an output file and print the win percentage of each team to the file and monitor. // Any addtional methods you like to add public static void main(String[] args) { //TODO // Declare objects and variables needed // call methods // Add any other necessary code } }

public class Team { //Team.java file

// TODO: Declare private fields - teamName, teamWins, teamLosses // TODO: Define Constructrs // default, parenthesized, copy // TODO: Define mutator methods - // setTeamName(), setTeamWins(), setTeamLosses() // TODO: Define accessor methods - // getTeamName(), getTeamWins(), getTeamLosses() // TODO: Define getWinPercentage() // TODO: Define toString() }

//team1.txt

36 44 Minnesota Twins 23 27 Los Angeles Dodgers 33 27 New York Yankees 40 20 Tampa Bay Rays

//team2.txt

36 -44 Minnesota Twins 23 27 Los Angeles Dodgers -33 27 New York Yankees 40 20 Tampa Bay Rays

//teams.txt

36 24 Minnesota Twins 43 17 Los Angeles Dodgers 33 27 New York Yankees 40 20 Tampa Bay Rays 32 28 Toronto Blue Jays 36 24 Boston Red Sox 36 24 Oakland Athletics 37 23 San Diego Padres 34 26 Chicago Cubs 22 38 Texas Rangers

blank.txt // output file must output to file and to monitor, crucial that this step is done.

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

5. Explain how ERISA protects employees pension rights.

Answered: 1 week ago

Question

25.0 m C B A 52.0 m 65.0 m

Answered: 1 week ago