Question: write a java program. To write a constructor with parameters, an method and a toString() method. To use ArrayList. To use a for-each loop. To

write a java program. To write a constructor with parameters, an method and a toString() method. To use ArrayList. To use a for-each loop. To use text file for output 2 The Context This is a single-class project, the first for which I have not given you code to start from. It is not realistic, or useful, but it gives us a place to start. This does not follow the MVC pattern for simplicitys sake. It is very important that you follow these instructions closely. They will guide you through learning a specific set of skills. Do not try to solve the problem some other way. The Olympian Class Create a class called Olympian" to hold the facts about a member of the 2018 USA Olympic Team: name, sport, numMedals and event. In this class, provide four private data members: name, sport, numMedals and event. Create a constructor with four parameters (name, sport, numMedals and event). Also provide a toString() method and a computeMedals() method. The compute function. In your computeMedals(), a static function, do all of the following: Take one parameter, an array of Olympian objects. Use a for-each loop to walk through the ArrayList. For each Olympian in the array: get the numMedals using an accessor method (getter). use the numMedals to add to the total number of medals for all the Olympians return the total number of medals. The main function. In your main function, do all of the following: Output a welcome message to the console that includes the assignment name, P3: Olympians and your name. Allocate an ArrayList of the class Olympian. In a loop, read in the name, sport, numMedals and event of each Olympian. Use these to create an Olympian object and add it to the Olympians ArrayList. Validate input for NumMedals. It cannot be negative or more than 10 (Michael Phelps has 8) but it can be zero. When input is finished, call the function named computeMedals(), described above, and receive a return value that is the total medals received by all the Olympians in your list. Print this to the console with an appropriate label. Use a for-each loop to print the array of Olympians and show their name, sport, numMedals and event. Use proper labels and spacing so it looks like a table. Open a file named results.txt for output and declare a PrintWriter. Use a for-each loop to print the array of Olympians into the file and show their name, sport, numMedals and event. Make the columns line up by formatting the output. You may want a printRow() function for this. Put a line of = at the bottom of the numMedals column, then show the total number of medals. Dont forget to close your PrintWriter. Print a departing message thanking your user. Optional challenges: Use MVC pattern and use multiple classes. Keep track of Gold, Silver and Bronze medals separately. Show sum by medal type and total of all medals at the bottom of the console output and the file output. Read data from an input file that contains the data you cut and pasted from the https://en.wikipedia.org/wiki/United_States_at_the_2018_Winter_Olympics Links to an external site.. Read the data into the ArrayList (note how will you handle team events?) Medal Name Sport Event Date Gold Redmond GerardLinks to an external site. SnowboardingLinks to an external site. Men's slopestyleLinks to an external site. February 11 Gold Jamie AndersonLinks to an external site. SnowboardingLinks to an external site. Women's slopestyleLinks to an external site. February 12 Gold Chloe KimLinks to an external site. SnowboardingLinks to an external site. Women's halfpipeLinks to an external site. February 13 Gold Shaun WhiteLinks to an external site. SnowboardingLinks to an external site. Men's halfpipeLinks to an external site. February 14 Silver Chris MazdzerLinks to an external site. LugeLinks to an external site. Men's singlesLinks to an external site. February 11 Bronze Nathan ChenLinks to an external site. Alexa Scimeca KnierimLinks to an external site. Chris KnierimLinks to an external site. Mirai NagasuLinks to an external site. Adam RipponLinks to an external site. Alex ShibutaniLinks to an external site. Maia ShibutaniLinks to an external site. Bradie TennellLinks to an external site. Figure skatingLinks to an external site. Team eventLinks to an external site. February 12 Bronze Arielle GoldLinks to an external site. SnowboardingLinks to an external site. Women's halfpipeLinks to an external site. February 13 3 Testing, Documentation, and Submission. Use the Eclipse Project menu Generate Javadoc option, to run the Javadoc application. Tell Javadoc to put your documentation in the project folder. It generates a lot of files (.html). Open the Javadoc and take a screen shot or print to a .pdf of the Olympians class page. Hand in this screen shot/.pdf, not the entire Javadoc html. Run your program using several test cases (enough to test all parts of the program). Copy the output and put it all into one file. Label each test clearly with a clear description. Add your own test cases to the end. For no Olympians, the program must still end gracefully. For example: Label the test 1 like this: +++++++++++++++++ Test 1 Zero Olympians +++++++++++ Test the program at least three times, Test one with a no Olympians, Test two with 1 Olympian, Test three with at least 10 or more Olympians. Create a folder named .sec# Put the source code (.java) file into the directory. Add the screen shot/.pdf of your Javadoc class page for Olympians.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!