Rullst AcademyRullst Academy/Lesson
Rust: from idea to program · Lesson 08 / 08

Project: scoring station

Let’s combine values, decisions, loops, functions, borrowing and Option in a program you can download and run.

Learning paths14 min

Let's discover together

  1. 1

    Project contract: each correct answer earns 10 points. Rounds with three or more correct answers get 5 extra points. Examples use zero through five correct answers.

  2. 2

    Separate responsibilities: bonus decides whether there is an extra using Option; score calculates points; report takes the name as &str and builds a message with format!.

  3. 3

    format! uses slots such as {} to insert values and returns a String. Unlike println!, it does not print by itself. main decides what to display and traverses rounds with for.

  4. 4

    Before running, predict cases with no correct answers, below the bonus threshold and at it. The ZIP includes automated tests, comments in your selected language and instructions for cargo run and cargo test.

  5. 5

    This project uses Rust and its standard library, without Rullst. Rullst Academy’s first track exports a web app using Rullst 12. The language is the shared foundation; the framework adds web application tools.

✦
YOUR MISSION

Build the scoring rule and check three scenarios before downloading the Rust project.

Now it's your turn

Discovery workshop

Build and check your rule

Each correct answer earns 10. Starting at 3 correct answers, add 5. Set the three constants and predict results. This is a guided assembly activity; the ZIP contains the runnable Rust program.
Your snippet in progress
fn score(correct: u32) -> u32 {
    let base = correct * {1};
    if correct >= {3} { base + {2} } else { base }
}
// score(0): {4}?  score(2): {5}?  score(3): {6}?
Build your answers and check when you are ready.
A moment to understand

What best checks the rule before expanding the program?

I need a hint

A rule can get one example right and fail at the boundary.

Loading your journey…

How can I tell what I learned?

Use the objectives and challenge below for reflection or a conversation with someone who can help. This is guided self-assessment: it sends no answers, awards no XP and does not automatically verify independence.

In Foundations, change an example, predict results, check a normal case and an error case, and explain your choices. If you need help, identify what to practice again.

Your transfer challenge

In the downloaded project, try changing points per answer or the bonus threshold. Update expected test results first, then adjust the rule and check cargo test.

Keep evidence: prediction, attempt, result, an original change and what you still cannot explain. Seek feedback when possible; if studying alone, return later without copying and compare attempts.

Try again another time

After a break, explain the idea without opening the solution and try a different example. Compare with your first attempt: what can you do independently, and where do you need a hint? You may write, speak or draw; choose a way to check the same idea. Record help received, including AI, and revisit the part you need. There is no universal deadline or extra XP for this record.

Completions and XP record Rullst Academy assessments. An introductory track can help everyday life and prepare further study; alone it does not prove complete mastery or professional readiness. Level indicates depth, not age.

Take it with you

In the downloaded project, try changing points per answer or the bonus threshold. Update expected test results first, then adjust the rule and check cargo test.

Show me the Rust behind it

This part is optional. You don't need to memorize the code to continue.

fn bonus(correct: u32) -> Option<u32> {
    if correct >= 3 { Some(5) } else { None }
}

fn score(correct: u32) -> u32 {
    let base = correct * 10;
    match bonus(correct) {
        Some(extra) => base + extra,
        None => base,
    }
}

fn report(name: &str, correct: u32) -> String {
    format!("{name}: {}", score(correct))
}

fn main() {
    let name = String::from("Robo");
    for correct in 0..=5 {
        println!("{}", report(&name, correct));
    }
}
At your own pace

My files and GitHub

Every lesson can become your own record: code, notes or a practice plan. Saving a file to GitHub is optional and does not change your XP.

Student guide

The editor and downloads open when this lesson is available to your account. Check access below or return to the track map.

Checking your access to this lesson…

Rullstpetbot

AI can make mistakes. Check the lesson material.