Fruit Prices
Create a HashMap with 3 fruits and their prices, then print each one. Use these fruits and prices:
"apple"costs1.50"banana"costs0.75"cherry"costs2.00
Print them in alphabetical order, one per line, in the format fruit: $price.
Expected output:
text
apple: $1.5 banana: $0.75 cherry: $2
Hints:
- Use
HashMap::new()and.insert()to add entries - Collect the keys into a vector, sort it, then loop through the sorted keys
- Use
map[key]to look up the value for each key
rust
fn main() {
}