Important Notice:

Practice-It will be discontinued as of November 1st, 2024. After this date, the website will remain online for a transitional period, but login will be restricted to University of Washington NetID authentication. This marks the next phase towards the platform's full retirement. Thank you for your use and support of the application over the years.

If you are looking for an alternative, a similar tool, CodeStepByStep, was developed independently by the original author of Practice-It, and is available at codestepbystep.com**

logo Practice-It logo

reportScore

Language/Type: Java file processing Scanner
Author: Marty Stepp (on 2020/04/16)

Write a static method called reportScore that takes as a parameter a Scanner containing information about a student's performance and that prints a report for that student. Students are given gold stars for tasks they solved particularly well and minuses for tasks where they performed poorly. The information for each student is presented as a series of count/type pairs where each count is a positive integer and each type is either "*" or "-". These count/type pairs are followed by the student's name which is guaranteed to be a single word composed entirely of alphabetic characters. Consider this report:

3 * 2 - 1 * Erica

It indicates that Erica got 3 stars followed by 2 minuses followed by 1 star. The overall score is computed by giving 1 plus point for each star and one minus point for each minus. The method produces exactly one line of output reporting this score and the total number of tasks. The table below includes several examples.

        Scanner contents                       Output produced
        ----------------------------------     ------------------
        3 * 2 - 1 * Erica                      Erica got 2 of 6
        2 - 1 * 2 - 1 - 1 * 2 - Fred           Fred got -5 of 9
        1 * 1 - 3 * 1 - 2 - Sylvia             Sylvia got 0 of 8
        Julia                                  Julia got 0 of 0

You may not construct any extra data structures to solve this problem.

Type your solution here:


This is a method problem. Write a Java method as described. Do not write a complete program or class; just the method(s) above.

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.