i dont know where to start with this code i have
heres a link to the programCode:#include <iostream> #include <string> using namespace std; int main() { //char ans = 'y'; short left_numbers,last_number;//numbers left over long input;//user input string suffix_1 = "st"; string suffix_2 = "nd"; string suffix_3 = "rd"; string suffix_beyond = "th"; cout<<"what is your number?\n"; cin>>input; left_numbers = input % 100;//special cases last_number = input % 10;//ordinary cases 0,1,2,etc if( (left_numbers <=13) && (left_numbers >= 11) )//special cases 11-13 { cout<<input<<suffix_beyond; } else if(last_number == 1)//suffix for 1 { cout<<input<<suffix_1; } else if(last_number == 2)//suffix for 2 { cout<<input<<suffix_2; } else if(last_number == 3)//suffix for 3 { cout<<input<<suffix_3; } else { cout<<input<<suffix_beyond; } return 0; }
http://home.earthlink.net/%7Ecraie/121/labs/suffix.html
i got the basics of the program to work; but i'm trying to add more levels to it:
Add (Level 2) to use functions to break your program into more manageable pieces. I'd recommend the display of the result go into a function to de-clutter the main.
In fact, you can probably break out another function from the results-display: the random pre-message generation. If you do, I'll throw in another (Level 1.5) to make just the random number formula into an inline function.
You can add a special (Level 1.5) to place your suffix-determining code in a generic/re-usable function.
Add (Level 1.5) to place your suffix function in a library.
Add (Level 1.5) to place your random number generation function in a library.
what are yall recommendations on starting a function in order to add these levels?
thanks in advance
btw,i'm still working on it. hopefully i'll figure it out soon



LinkBack URL
About LinkBacks


