Lab · Java Programming (Core to Spring Boot)
Lab: a class marks report
The brief
A tuition teacher in Kolkata pastes her students' unit-test marks as one messy line of text. You turn it into arrays, work out the total, average, topper and median, find a student by name, and print a neat report card with grades.
Why it matters
Real data almost always arrives as text: a CSV export, a form, a chat message. Splitting, cleaning and parsing it, then working over arrays, is daily work for developers in ed-tech, HR and banking. The bugs here (stray spaces, integer averages, sorting the original by mistake, == on Strings) are the classic ones.
Skills you practise
- String.split and strip
- Integer.parseInt
- arrays and loops
- Arrays.toString, copyOf and sort
- equalsIgnoreCase
- StringBuilder and String.format
You need
- JDK 21 (Eclipse Temurin from adoptium.net or Oracle JDK; JDK 17 or any newer version also works)
- A text editor or IDE (VS Code with the Extension Pack for Java, or IntelliJ IDEA Community Edition) and a terminal
What you will have at the end
Marks.java that turns a line of raw text into a complete marks report: statistics, a search and an aligned report card.
How it is marked (rubric, 100 points)
| Correct resultsEvery check passes: clean names, 72.83, the untouched original, 73.5, the search and every grade including the 75 boundary. | 45 |
|---|---|
| Arrays and Strings used wellParallel arrays kept in step, a sorted copy, equalsIgnoreCase, one StringBuilder. | 25 |
| Readable codeClear names, no repeated blocks, the grade rule written once. | 15 |
| Can explain itYou can explain why == fails for the search and why the original must not be sorted. | 15 |
0/5 steps done
Step 1 of 5
Split the text into arrays
The program prints Students: 6 and Names: [Asha, Ravi, Meena, Arjun, Sana, Kiran].
split(",") cuts the line into one piece per student, such as " Ravi:45 ". Each piece still has spaces, so strip() it before splitting on ":" and parsing the number: Integer.parseInt("45 ") throws NumberFormatException. Make two arrays of the same length, names and marks, so index i means the same student in both. Arrays.toString prints an array readably.
$ javac Marks.java
java MarksYour notes: Marks.java
Write down each command you ran. It goes into your project summary.