fix: worked till if and quiz 1

This commit is contained in:
Raghu Ganapathy 2023-07-15 22:16:26 -07:00
parent 59e0adb455
commit e47d4c4c06
3 changed files with 22 additions and 12 deletions

View File

@ -1,13 +1,12 @@
// if1.rs
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn bigger(a: i32, b: i32) -> i32 {
// Complete this function to return the bigger number!
// Do not use:
// - another function call
// - additional variables
if(a>b){
return a;
}else{
return b;
}
}
// Don't mind this for now :)

View File

@ -4,16 +4,19 @@
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
// I AM NOT DONE
pub fn foo_if_fizz(fizzish: &str) -> &str {
if fizzish == "fizz" {
"foo"
} else {
1
if fizzish =="fuzz"{
"bar"
}else{
"baz"
}
}
}
// No test changes needed!
#[cfg(test)]
mod tests {

View File

@ -10,10 +10,18 @@
// Write a function that calculates the price of an order of apples given
// the quantity bought. No hints this time!
// I AM NOT DONE
// Put your function here!
// fn calculate_price_of_apples {
fn calculate_price_of_apples(no_of_apples:i32)->i32{
let mut price_of_apples :i32;
if no_of_apples >40{
price_of_apples = no_of_apples;
}else{
price_of_apples = 2*no_of_apples;
}
println!("Price of {} is {}",no_of_apples, price_of_apples);
return price_of_apples;
}
// Don't modify this function!
#[test]