Lesson 5.10 · Write it
Scores on one line
A whole programPython or Java6 tests, 4 of them hidden
On a phone? Put the lines in order instead
Write a program that reads one line holding a name and some test scores, and prints a short report.
- The line has the name first, then one or more scores. The parts are separated by commas, with no spaces around the commas. For example:
Ana,72,85,90. - The name has no commas in it, but it can have spaces. Every score is a whole number from 0 to 100.
- Print three lines:
Name:and the name, thenScores:and how many scores there are, thenTotal:and the scores added up.
For the example line, the program prints:
Name: Ana Scores: 3 Total: 247
Your program is run several times. Only what it prints is checked.
Running Java here comes later. You can put this answer's lines in order instead. You can still write your Java answer (it stays while this page is open) and compare it with our worked solution. Or try this exercise in Python.
Examples
Your program is run 6 times: the 2 examples below, and 4 hidden ones that check the rules above. Only what it prints is checked.
the example: a name and three scores (rule 3)
You type
- typed: Ana,72,85,90
It prints
Name: Ana Scores: 3 Total: 247
a name and only one score (rule 1)
You type
- typed: Leo,50
It prints
Name: Leo Scores: 1 Total: 50