Pizza Party
Given (number of pizzas, number of slices per pizza, number of people), divide the pizza slices among the people
This is a simple program using remainder and quotient operations.
#![allow(unused)] fn main() { let ntotal_slices = nslices_per_pizza * npizzas; let slices_per_person = ntotal_slices / npeople; let remainder = ntotal_slices % npeople; }
The function below handles the pluralization of the word "piece":
#![allow(unused)] fn main() { fn print_pieces(num: u64) -> String { if num > 1 { format!("{} pieces", num) } else { format!("{} piece", num) } } }