Exerpad
🔥 0
0 XP
Exercise 7 · Chapter: HashMapsRequired+50 XP

Student Grades

Create a HashMap that maps student names to their grades:

  • "Alice" got an "A"
  • "Bob" got a "B"
  • "Carol" got an "A"

Print each student and their grade in alphabetical order by name, in the format Name: Grade.

Expected output:

Alice: A
Bob: B
Carol: A

Hints:

  • Use .insert() to add each student
  • Collect keys, sort them, then loop through to print
rust
fn main() {
}
Output
Run your code to see the output here.