From 6f0202719d6a6cfc62c8a184018421a896f2eb8e Mon Sep 17 00:00:00 2001 From: Shaja Date: Mon, 8 Jul 2024 16:01:38 +0530 Subject: [PATCH] First quiz done --- exercises/03_if/if3.rs | 6 ++---- exercises/04_primitive_types/primitive_types1.rs | 2 +- exercises/quiz1.rs | 10 +++++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/exercises/03_if/if3.rs b/exercises/03_if/if3.rs index 16962740..f76aabce 100644 --- a/exercises/03_if/if3.rs +++ b/exercises/03_if/if3.rs @@ -2,17 +2,15 @@ // // Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE - pub fn animal_habitat(animal: &str) -> &'static str { let identifier = if animal == "crab" { 1 } else if animal == "gopher" { - 2.0 + 2 } else if animal == "snake" { 3 } else { - "Unknown" + 4 }; // DO NOT CHANGE THIS STATEMENT BELOW diff --git a/exercises/04_primitive_types/primitive_types1.rs b/exercises/04_primitive_types/primitive_types1.rs index 36633400..0972d3d0 100644 --- a/exercises/04_primitive_types/primitive_types1.rs +++ b/exercises/04_primitive_types/primitive_types1.rs @@ -13,7 +13,7 @@ fn main() { println!("Good morning!"); } - let // Finish the rest of this line like the example! Or make it be false! + let is_evening = true; // Finish the rest of this line like the example! Or make it be false! if is_evening { println!("Good evening!"); } diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 4ee5ada7..5a5936ba 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -13,10 +13,14 @@ // // No hints this time ;) -// I AM NOT DONE - // Put your function here! -// fn calculate_price_of_apples { +fn calculate_price_of_apples(quantity: i32) -> i32 { + return if quantity <= 40 { + quantity * 2 + } else { + quantity * 1 + } +} // Don't modify this function! #[test]