Introduction
You’ve just completed a journey that took you from your very first fn main() to mastering formatted output in Rust. This wasn’t just a programming course—it was a path of care, clarity, and intention.
This final project isn’t just a technical exercise. It’s a gesture of respect—toward those who will read your code, toward yourself, and toward the time you’ve invested. It’s your chance to show that precision isn’t pedantry—it’s kindness.
Goal
Build a program that calculates Body Mass Index (BMI), interprets it using standard medical ranges, and presents the result in a clear, elegant, and respectful way. The output should be:
- Functional: the calculation is correct.
- Explanatory: the meaning is clear.
- Formatted: the output is readable and well-structured.
- Empathetic: the final message is human.
Project Structure
1. Input
- Height in meters (float)
- Weight in kilograms (float)
2. Calculation
- BMI formula:
weight / (height * height)
3. Interpretation
| Category | BMI Range |
|---|---|
| Underweight | < 18.5 |
| Normal | 18.5 – 24.9 |
| Overweight | 25.0 – 29.9 |
| Obesity | ≥ 30.0 |
4. Output
- ASCII-bordered table
- ANSI colors (if supported)
- Reference ranges
- Personalized interpretation message
Full Code
fn main() {
let height_m = 1.75;
let weight_kg = 68.0;
let bmi = weight_kg / (height_m * height_m);
display_result(height_m, weight_kg, bmi);
}
fn display_result(height: f64, weight: f64, bmi: f64) {
let use_colors = std::env::var("NO_COLOR").is_err();
let (reset, dim, bold, green, yellow, red) = if use_colors {
("\x1b[0m", "\x1b[2m", "\x1b[1m", "\x1b[32m", "\x1b[33m", "\x1b[31m")
} else {
("", "", "", "", "", "")
};
let category = interpret_bmi(bmi);
let colored_category = match category {
"Normal" => format!("{green}{category}{reset}"),
"Underweight" | "Overweight" => format!("{yellow}{category}{reset}"),
"Obesity" => format!("{red}{category}{reset}"),
_ => category.to_string(),
};
let h = format!("{:.2}", height);
let w = format!("{:.1}", weight);
let b = format!("{:.2}", bmi);
let title = format!("{bold}BMI SUMMARY{reset}");
let ranges = format!(
"{dim}Ranges → Under: <18.5 | Normal: 18.5–24.9 | Overweight: 25–29.9 | Obesity: ≥30{reset}"
);
let top_border = "┌─────────────────────────────────────────┐";
let mid_border = "├─────────────────────────────────────────┤";
let bottom_border = "└─────────────────────────────────────────┘";
println!();
println!("{top_border}");
println!("│ {:^41} │", title);
println!("{mid_border}");
println!("│ {:<12} {:>26} │", "Height:", format!("{h} m"));
println!("│ {:<12} {:>26} │", "Weight:", format!("{w} kg"));
println!("│ {:<12} {:>26} │", "BMI:", b);
println!("│ {:<12} {:>26} │", "Category:", colored_category);
println!("{mid_border}");
println!("│ {:<41} │", ranges);
println!("{bottom_border}");
println!();
println!("{bold}Interpretation:{reset}");
match category.as_str() {
"Underweight" => println!("Your BMI indicates you are below the ideal weight. Consider consulting a health professional."),
"Normal" => println!("Your BMI is within the normal range. Keep up your healthy lifestyle!"),
"Overweight" => println!("Your BMI is above the normal range. Reviewing your diet and activity may be helpful."),
"Obesity" => println!("Your BMI is high. We recommend speaking with a doctor for a full evaluation."),
_ => println!("Unrecognized category."),
}
}
fn interpret_bmi(bmi: f64) -> &'static str {
match bmi {
x if x < 18.5 => "Underweight",
x if x < 25.0 => "Normal",
x if x < 30.0 => "Overweight",
_ => "Obesity",
}
}
What You’ve Learned
- How to structure a complete Rust program
- How to separate logic and presentation using functions
- How to format numbers and strings
- How to use ANSI colors for clarity
- How to communicate respectfully through code
Why “Precision is a Form of Respect”?
Because every detail matters. A well-aligned output isn’t just aesthetic—it’s accessible. A clear message isn’t just informative—it’s kind. Readable code isn’t just technical—it’s thoughtful.
When you write code, you’re speaking to other humans. And when your code says “I care,” you’ve already made the leap from Zero to WoW.
What’s Next?
You’ve finished the course—but not your learning journey. Here are some ideas to keep going:
- 🧩 Extend the project: Add keyboard input, file saving, or JSON export.
- 🌐 Build a web interface: Use
YeworTaurito turn it into an app. - 🌍 Localize your output: Translate it into English, French, or any language you like.
- 🧪 Write tests: Use
cargo testto verify your logic. - 📦 Publish your project: Create a GitHub repo and share it with the world.
Thank You
Thank you for your time, attention, and curiosity throughout this course. I hope you’ve learned not just Rust, but a way of thinking: precise, respectful, and human.
Disclaimer
This project is for educational purposes only. The BMI interpretations are simplified and do not replace professional medical advice. For clinical evaluations, always consult a qualified healthcare provider.
