mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mikysett
53f7ded2f2
|
2 years ago | |
---|---|---|
.. | ||
README.md | 2 years ago |
README.md
negative_spelling
Instructions
In this exercise, you'll create the function negative_spell
that will spell a negative number.
Here are some examples of what your function should return:
-1
->"minus one"
-14
->"minus fourteen"
-348
->"minus three hundred forty-eight"
-1002
->"minus one thousand two"
Only negative numbers will be accepted, up to
"minus one million"
. If a positive number is passed the function should return"error: positive number"
.
Expected function
pub fn negative_spell(n: i64) -> String {
}
Usage
Here is a program to test your function.
use negative_spelling::*;
fn main() {
println!("{}", negative_spell(-1234));
println!("{}", negative_spell(100));
}
And its output:
$ cargo run
minus one thousand two hundred thirty-four
error: positive number
$