<分区>
我已经接受了用户的输入,但是当我尝试比较时,它没有输入 if 或 else if block 。相反,它转到其他 block
use std::io;
fn main() {
let small_coffee = 2;
let medium_coffee = 4;
let large_coffee = 6;
let mut total_price = 0;
let mut user_choice = String::new();
io::stdin().read_line(&mut user_choice).ok().expect("Eror");
if user_choice == "1" {
total_price += small_coffee;
} else if user_choice == "2" {
total_price += medium_coffee;
} else if user_choice == "3" {
total_price += large_coffee;
} else {
println!("Sorry! Invalid Choice");
}
println!("Your total bill amounted to : {}$", total_price);
}