mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-06 10:03:30 +02:00
done until quiz1
This commit is contained in:
@@ -11,6 +11,18 @@
|
||||
// TODO: Write a function that calculates the price of an order of apples given
|
||||
// the quantity bought.
|
||||
// fn calculate_price_of_apples(???) -> ??? { ??? }
|
||||
fn calculate_price_of_apples(apples: i32) -> i32 {
|
||||
let mut cost: i32 = 2;
|
||||
|
||||
if apples > 40 {
|
||||
cost = 1;
|
||||
cost *= apples;
|
||||
cost
|
||||
} else {
|
||||
cost *= apples;
|
||||
cost
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// You can optionally experiment here.
|
||||
|
||||
Reference in New Issue
Block a user