Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Logic

This program checks if someone can ride a roller coaster. It reads height (cm) and age from input (one per line). The rules are:

  • You must be at least 120 cm tall AND at least 8 years old

But the programmer mixed up the boolean operators! Fix the logic so it works correctly.

Hint: Should this be && (AND) or || (OR)? Think about what the rules say — do you need both conditions to be true, or just one?

rust
use std::io;

fn main() {
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
let height: i32 = input.trim().parse().unwrap();

input.clear();
io::stdin().read_line(&mut input).unwrap();
let age: i32 = input.trim().parse().unwrap();

if height >= 120 || age >= 8 {
println!("You can ride!");
} else {
println!("Sorry, you can't ride yet.");
}
}