Answered Essay: 10:53 AM a bbprod.hwcc.edu 00 Verizon Create a program called TennisArrayList.java This program will open a file, tennisplayers.txt, for reading. Thi

10:53 AM a bbprod.hwcc.edu 00 Verizon Create a program called<yourName> TennisArrayList.java This program will open a file, tennisplayers.txt, for reading. This input file contains tennis player information. Your program will create a method called fillTennisArrayList) that will read from the file and create a TennisPlayer ArrayList. Then, you will create a method called printTennisPlayers) that will print the contents of the ArrayList. Files to submit: <yourName> TennisPlayer.java (the most recent one, from Lecture Module 10) <yourName>TennisArrayList.java TennisArrayList.java main0 Create an ArrayList of type TennisPlayer. Then call two methods, fillTennisArrayList0 and printTennisPlayersO with the ArrayList as the argument. fillTennisArrayList0 This method defines one parameter, an ArrayList of type TennisPlayer The input file includes information about a number of tennis players. For each player, their name, country, rank, age, wins and losses are provided, each on its own line The file provided includes information for seven players, but the file may contain information for any number of players. However, the format of six lines for each player will be the same and the information will be in the same order Iterate through the file using a while loop. For each tennis player, obtain all the information for that player, create a TennisPlayer object using the information from the file, and add the TennisPlayer object to the ArrayList.
media%2F503%2F5039b6e4-84df-41bb-a374-8c
media%2F858%2F858c9d34-3f14-4190-a772-80
media%2F5c7%2F5c7d18e3-09f1-455f-99ac-0c

10:53 AM a bbprod.hwcc.edu 00 Verizon Create a program called TennisArrayList.java This program will open a file, tennisplayers.txt, for reading. This input file contains tennis player information. Your program will create a method called fillTennisArrayList) that will read from the file and create a TennisPlayer ArrayList. Then, you will create a method called printTennisPlayers) that will print the contents of the ArrayList. Files to submit: TennisPlayer.java (the most recent one, from Lecture Module 10) TennisArrayList.java TennisArrayList.java main0 Create an ArrayList of type TennisPlayer. Then call two methods, fillTennisArrayList0 and printTennisPlayersO with the ArrayList as the argument. fillTennisArrayList0 This method defines one parameter, an ArrayList of type TennisPlayer The input file includes information about a number of tennis players. For each player, their name, country, rank, age, wins and losses are provided, each on its own line The file provided includes information for seven players, but the file may contain information for any number of players. However, the format of six lines for each player will be the same and the information will be in the same order Iterate through the file using a while loop. For each tennis player, obtain all the information for that player, create a TennisPlayer object using the information from the file, and add the TennisPlayer object to the ArrayList.

Expert Answer

 

TennisPlayer.java:

public class TennisPlayer {

private String name, country;

private int rank, age, wins, losses;

public TennisPlayer(String name, String country, int rank, int age,

int wins, int losses) {

this.name = name;

this.country = country;

this.rank = rank;

this.age = age;

this.wins = wins;

this.losses = losses;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getCountry() {

return country;

}

public void setCountry(String country) {

this.country = country;

}

public int getRank() {

return rank;

}

public void setRank(int rank) {

this.rank = rank;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

public int getWins() {

return wins;

}

public void setWins(int wins) {

this.wins = wins;

}

public int getLosses() {

return losses;

}

public void setLosses(int losses) {

this.losses = losses;

}

@Override

public String toString() {

StringBuilder sb = new StringBuilder();

sb.append(“——————————n”);

sb.append(“Tennis Player: ” + name + “n”);

sb.append(“Country: ” + country + “nn”);

sb.append(“Current Rank: ” + rank + “nn”);

sb.append(“Age: ” + age + “nn”);

sb.append(“Wins: ” + wins + “n”);

sb.append(“Losses: ” + losses + “nn”);

double percentage = Math.floor((double)wins * 10000/(wins + losses))/100;

sb.append(“Winning Percentage: ” + percentage + “%n”);

sb.append(“——————————“);

return sb.toString();

}

}

TennisArrayList.java:

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.util.ArrayList;

import java.util.Scanner;

public class TennisArrayList {

public static void main(String[] args) throws FileNotFoundException {

ArrayList<TennisPlayer> playersList = fillTennisArrayList();

printTennisPlayers(playersList);

}

public static void printTennisPlayers(ArrayList<TennisPlayer> playersList) {

for(TennisPlayer player: playersList) {

System.out.println(player);

}

}

/*

* Below method reads the data from a file named as players.txt in the same directory

*

*/

private static ArrayList<TennisPlayer> fillTennisArrayList() throws FileNotFoundException {

final String FILE_NAME = “players.txt”;

System.out.println(“reading file ” + FILE_NAME + ” from directory: ” + System.getProperty(“user.dir”));

ArrayList<TennisPlayer> playersList = new ArrayList<>();

Scanner reader = new Scanner(new FileReader(FILE_NAME));

while(reader.hasNextLine()) {

String name = reader.nextLine();

String country = reader.nextLine();

int rank = Integer.parseInt(reader.nextLine());

int age = Integer.parseInt(reader.nextLine());

int wins = Integer.parseInt(reader.nextLine());

int losses = Integer.parseInt(reader.nextLine());

// create new player

TennisPlayer tp = new TennisPlayer(name, country, rank, age, wins, losses);

// add player to list

playersList.add(tp);

}

System.out.println(“List of players populated successfully”);

reader.close();

return playersList;

}

}

players.txt:

Player1
Country1
5
12
13
4
Player2
Country2
3
11
16
3

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?