From 01f7d29148a6030e41a690b60709de128e8dacaf Mon Sep 17 00:00:00 2001 From: David Bailey <davidbailey00@outlook.com> Date: Sat, 16 Jan 2021 20:37:46 +0000 Subject: [PATCH] Add quiz1 solution --- exercises/quiz1.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 5c5c355..75c5f79 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -7,10 +7,14 @@ // more than 40 at once, each apple only costs 1! Write a function that calculates // the price of an order of apples given the order amount. No hints this time! -// I AM NOT DONE - // Put your function here! -// fn ..... { +fn calculate_apple_price(amount: i32) -> i32 { + if amount > 40 { + amount + } else { + amount * 2 + } +} // Don't modify this function! #[test]