Standings Line (Arrays and Methods) Synopsis Create a program that prints out some information…

Standings Line (Arrays and Methods)

Synopsis

Create a program that prints out some information that might appear in a table that shows the standings of teams in a sports league

We’ll only have wins, losses and ties. No overtime or shoot-out wins or losses. We also won’t track goals for and against.

The program reads in a list of wins, losses and ties. It reports back several items of interest.

Details

Your program executes the following steps, in the following order — using methods in most steps:

  1. It introduces itself and you in the standard way (title, short self-description, your name and student number). It pauses after printing the introduction.
  2. It prompts for and reads up to 100 game results. If the list of results is less than 100, it ends with any item that is not a valid game result (that is, not a W, L or T). The game results may be entered in lower case or upper case, but are saved in the array as upper case.
  3. It echoes back the results in a compact form — one line, with no spaces or punctuation between the elements (it’ll look like one long String). The program pauses after echoing back the input.
  4. It outputs the won-lost-tied record. This record is in the form “wins-losses-ties”.
  5. It outputs the number of points for this record. The team gets 2 points for each win, and one point for each tie. The program pauses here.
  6. It retrieves and shows the last 10 game results — or all the game results if there were fewer than 10. This again is the compact form used in step 3.
  7. It shows the won-lost-tied record for the “last 10” games, and the number of points for that record. (Of course, if there are less than 10 games, the record and points will be the same as it was earlier — but that’s exactly what we expect.) The program pauses one last time.

In writing your program, you will create and use the following (static!) methods:

  • printIdentification() — for use in step 1.
  • String[] readArray(int maxToRead) — for use in step 2.
  • printArray(String[] arr) — for use in steps 3 and 6. It prints the elements of arr in the compact way described above.
  • String getRecord(String[] arr) — for use in steps 4 and 7. This method returns the record as a String — for example “3-0-0” or “2-1-1”.
  • int count(String result, String[] arr) — for use with getRecord and getPoints. This method goes thru each element of the array and counts how many times the given result appears. It returns the count. You will use this method, for example, to count how many times “W” appears in the list of results — which is how many wins are in that results list.
  • int getPoints(String[] arr) — for use in step 5.
  • String[] getLast(int num, String[] arr) — for use in step 6. Remember, if there are less than num elements in arr, then you will be returning all the elements. Do not print an error message.

Reminders and Warnings:

Remember to start with the steps of your program (the 7 steps listed above) as pseudo-code comments in your program. It will help keep you from biting off too-big pieces of code to do.

Remember to start with stubs of all the methods you require.

And remember that a stub is a very short method definition — usually the shortest one that’ll compile — and that it almost never does the right thing.

Remember also that the methods you need here are static.

Finally, make sure that you understand the job of each of the required methods. Make sure that your implementation does that job and no other. And make sure that you use each method in the required way. Your main is going to be mostly method calls and output commands. Most of the “work” is going to be in the other methods.

Hints

When reading in the game results, make an array that’s big enuf to hold all 100 games. Make your for loop to read in all 100 games, BUT check each result after reading it. If it’s a valid game result, add it to the array and count it. If it’s not a valid game result, then bump your loop control variable up to 100.

Sample Output:

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

w w w w l w w l w t w l w w w w w x

As a check, here is the data you entered:

WWWWLWWLWTWLWWWWW

Press enter…

Your won-lost-tied record is 13-3-1.

The number of points for that record is 27.

Press enter…

The last ten of those games:

LWTWLWWWWW

Your won-lost-tied record is 7-2-1.

The number of points for that record is 15.

Press enter…

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

w w w w l w w l w w l w w w w w .

As a check, here is the data you entered:

WWWWLWWLWWLWWWWW

Press enter…

Your won-lost-tied record is 13-3-0.

The number of points for that record is 26.

Press enter…

The last ten of those games:

WLWWLWWWWW

Your won-lost-tied record is 8-2-0.

The number of points for that record is 16.

Press enter…

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

L L L L L L L L L L L L L L

done

As a check, here is the data you entered:

LLLLLLLLLLLLLL

Press enter…

Your won-lost-tied record is 0-14-0.

The number of points for that record is 0.

Press enter…

The last ten of those games:

LLLLLLLLLL

Your won-lost-tied record is 0-10-0.

The number of points for that record is 0.

Press enter…

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

W l l l w t T ;

As a check, here is the data you entered:

WLLLWTT

Press enter…

Your won-lost-tied record is 2-3-2.

The number of points for that record is 6.

Press enter…

The last ten of those games:

WLLLWTT

Your won-lost-tied record is 2-3-2.

The number of points for that record is 6.

Press enter…

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

w w w w w w w w w w

As a check, here is the data you entered:

WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Press enter…

Your won-lost-tied record is 100-0-0.

The number of points for that record is 200.

Press enter…

The last ten of those games:

WWWWWWWWWW

Your won-lost-tied record is 10-0-0.

The number of points for that record is 20.

Press enter…

Standings Line Generator

————————

This program prints out some stuff that might be useful if you’re printing out

standings charts for some sports league.

by Ben Adam

Press enter…

Enter the game results here:

NONE

As a check, here is the data you entered:

Press enter…

Your won-lost-tied record is 0-0-0.

The number of points for that record is 0.

Press enter…

The last ten of those games:

Your won-lost-tied record is 0-0-0.

The number of points for that record is 0.

Press enter…

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!