-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeaje.rs
37 lines (31 loc) · 970 Bytes
/
peaje.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::io;
fn main() {
let mut categoria = String::new();
let mut tarifa = String::new();
let mut total = 0;
// Entrada de la categoría
println!("Ingrese categoria: ");
io::stdin().read_line(&mut categoria).unwrap();
let categoria = categoria.trim();
// Entrada de la tarifa
println!("Ingrese tarifa: ");
io::stdin().read_line(&mut tarifa).unwrap();
let tarifa = tarifa.trim();
// Cálculo del total
if categoria == "auto" || categoria == "camioneta" {
total = if tarifa == "normal" { 2000 } else { 3000 };
} else if categoria == "moto" {
total = if tarifa == "normal" { 600 } else { 900 };
} else if categoria == "camion" || categoria == "bus" {
total = if tarifa == "normal" { 3500 } else { 5200 };
}
// Mostrar el ticket
println!(
r#"
------ TICKET ------
Categoria: {categoria}
Tarifa: {tarifa}
Total: ${total}
"#
);
}