Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My CSCI 40 teacher made an assignment and I cant figure it out... He wants us to create a program that will transfer regular numbers

My CSCI 40 teacher made an assignment and I cant figure it out... He wants us to create a program that will transfer regular numbers into mandarin, he provided all the translations and explanations... We are using c++ to program... Ive posted screenshots of my code so farimage text in transcribedimage text in transcribed

Ask the user ----> Please enter a number that you want to count up to in Mandarin.

Ask the user ----> Please enter what number to start with:

Ask the user ---> What step size do you want to use?

input the users inputs

Your program should output the numbers in both Arabic numerals and in Mandarin.

For example, if you want to count to 10, starting at one, with a step size of two, your program will output this: 1 yi 3 san 5 wu 7 qi 9 jiu

We will not output anything past this, since the next number is over 10.

Mandarin Dictionary: 0 - ling 1 - yi 2 - er 3 - san 4 - si 5 - wu 6 - liu 7 - qi 8 - ba 9 - jiu 10 - shi

To count numbers over 10, use the following rules:

For numbers 11 through 19, it is shi followed by the digit above: 11 - shi yi 12 - shi er 13 - shi san etc.

For numbers 20 through 99, it is the first digit followed by shi followed by the second digit (except 0): 33 - san shi san 52 - wu shi er 80 - ba shi

For numbers over a hundred, it follows the same pattern. 167 in Mandarin is literally "1 hundreds, 6 tens, 7" or "yi bai liu shi qi". 420 in Mandarin is "4 hundreds 2 tens" or "si bai er shi". Same goes for thousands - 1234 is literally "one thousand 2 hundred three ten four" or "yi qian er bai san shi si". And so forth for wan (10,000s). Don't worry about digits over wan. 100 - bai 1000 - qian 10000 - wan

ERROR CHECKING: If the user ever makes an error on input, print "BAD INPUT!" to the screen and quit.

Types of errors: 1) Typing in something not an integer 2) Having the start be higher than the end 3) Having negative numbers 4) Having numbers over 99999 5) Having a step size of 0 or less

#include #include #include using namespace std; int main() { int x = 0; int y = 0; int z = 0; const string mandarin[] = { "ling", "yi", "er", "san", "si", "w", "liu", "qi", "ba", "jiu", "shi"}; cout > x; if (!cin) { cout 99999) { cout > y; if (!cin) { cout x) { cout > z; if (!cin) { cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

8. Provide recommendations for how to manage knowledge.

Answered: 1 week ago

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago