This activity was easy. No programming language required work, maybe that's why I feel it's easy to complete.

This commit is contained in:
Seoyeon Lee 2024-12-08 00:03:24 -05:00
parent 44f875c624
commit 122a47f7d4
1 changed files with 26 additions and 6 deletions

View File

@ -37,19 +37,39 @@ return digit_names[number]
## Integers under 20 ## Integers under 20
If the integer is under 10, then use the procedure described above. If the integer is under 10, then use the procedure described above.
Otherwise, ... (this is where you take over!) Otherwise, ... (this is where you take over!)
digit_names2 = [
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
"eighteen", "nineteen"
]
to get the digit, we devide the number by 10, and consider the remainder.
return dignt_names2 [number%10]
## Integers under 100 ## Integers under 100
If the integer is under 20, use the previous procedure. Otherwise, for the numbers from 20 to 99,
we do this.
digit_names3 = [
"twenty", "thirty" , ....... "eighty", "ninety"
]
We take first digit, get the name from the digit_names3.
Digit 1 = digit_names3 [number//10-2]
add hypen and add digit names [number%10]if the second digit is not zero. Else, add nothing.
## Integers under 1000 ## Integers under 1000
Digit 1 = digit_names [number//100]
add "hundred"
R1 = number%100
If R1 is not zero, we add "and", then we call Integers under 100 procedure on R1.
## Integers under 1000000 ## Integers under 1000000
Q1 = number//1000
We call Intergers under 1000 procedure on Q1
We add "thousand"
R1 = number%1000
If R1 is not zero, we call Integers under 1000 procedure on R1
## Negative integers down to -1 million ## Negative integers down to -1 million
We won't deal with negative integers in this problem set, We won't deal with negative integers in this problem set,
but how would you deal with a negative integer, using the but how would you deal with a negative integer, using the
functions above? functions above?
Number multiped by negative 1, we treat it as a new number.
We call the same function as before (now it's positive number)
We write "negative" in the begining of the answer.