Exercise 6 · Chapter: ConditionsRequired+50 XP
Fix the Comparison
This program reads a score from input and checks if a student passed or failed, but the comparison operators are wrong!
A student passes if their score is 70 or above. Fix the comparison operators so the program works correctly.
Hint: Think carefully about which direction the comparison should go. Is < the same as >=?
Expected output
You passed!
rust
use std::io;
fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let score: i32 = input.trim().parse().unwrap();
if score < 70 {
println!("You passed!");
} else {
println!("You failed.");
}
}
Output
Run your code to see the output here.