Skip to content
AgileLogics
Beginner 5 min read

Beginner Projects

Prerequisites: Level 1 — Beginner

Build these with nothing but what Level 1 covered — println!, stdin input, match, Vec, structs, and enums.

1. Command-Line Calculator

Read two numbers and an operator (+ - * /) from stdin, parse them with .parse::<f64>(), and match on the operator to print the result. Print a friendly message for division by zero, an unknown operator, or input that isn't a number — without ever calling .unwrap().

2. Number Guessing Game

Pick a secret number (add the rand crate with cargo add rand, or derive one from the current time with std::time::SystemTime), then loop, reading guesses and printing "Too high" / "Too low" until the player guesses correctly. Use std::cmp::Ordering with match.

3. Temperature Converter

Model the unit as an enum Unit { Celsius, Fahrenheit }, read a value and a unit, convert it to the other unit in a function that takes the enum, and print the result to one decimal place ({:.1}).

4. Console To-Do List

Store tasks in a Vec<Task>, where Task is a struct with a title: String and a done: bool. Loop over a menu (add / list / done / quit) handled with match, passing the vector to helper functions by & or &mut reference as appropriate.

5. Word Statistics

Read a line of text and print the number of words, the longest word, and the text with every word capitalized — practicing &str slices, split_whitespace(), and building a new String.