Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help with numbers 5, 9 and 10 listed below. /* Name: Tiffany LeRoux Descr

ID: 3656076 • Letter: I

Question

I need help with numbers 5, 9 and 10 listed below. /* Name: Tiffany LeRoux Description: Map of user text */ #include #include #include #include #include using namespace std; int main( ) { map letters; // a map with char key and int data map ::iterator iter; // iterator for the map string user_text; // a user_text entered by the user string answer; // whether the user wants to re-run the program do { // 1. map must be cleared for each iteration of do-while letters.clear(); // get the user_text the user enters cout << endl << "Please enter a some text and press enter: "; getline( cin, user_text ); // iterate through the user_text entered for(unsigned int i = 0; i < user_text.size(); ++i) { // 2. check to see if letter is already in the user_text // 3. if the letter is not already in the map add it and make the count 1 // else the letter already exists and the count needs to increase by 1 if( iter == letters.end() ) { letters[user_text[i]]=1; } else { letters[user_text[i]]++; } } cout << endl; // print out the total letters in the user_text cout << "Total letters in the user text = " << user_text.size() << endl << endl; // Construct a nicely formatted table // Column 1 is a list of the characters in the user_text // Column 2 is the number of times each letter occurs in the user_text // Column 3 is the percent each letter occurs compared to total user_text characters // the decimal point is fixed and only two decimal places are shown // In the chart, a tab is listed as and space as // // References to help with formatting: // http://www.cplusplus.com/reference/iostream/ios_base/flags/ // http://www.cplusplus.com/reference/iostream/ios_base/precision/ // http://www.cplusplus.com/reference/iostream/ios_base/setf/ // http://www.cplusplus.com/reference/iostream/manipulators/setw/ // http://www.cplusplus.com/reference/iostream/manipulators/showpoint/ // 4. set justification left // 5. set to show two decimal places of precision for decimal numbers // display table header info cout << setw( 10 ) << left << "Char" << setw( 10 ) << left << "Count" << setw( 10 ) << right << "Percent" << endl; cout << "----------------------------------" << endl; // 6. iterate through the contents in the map using an iterator for( iter = letters.begin(); iter != letters.end(); ++iter ) { int TAB (0); int SPACE (0); // 7. set justification left // 8. display characters and character count in their columns if( iter -> first == ' ' ) // check for tab character { cout << setw (10) << left << "" << TAB << iter-> second << endl;// print out here } else if( iter -> first == ' ' ) // check for space character { cout << setw (10) << left << "" << SPACE << iter-> second << endl;// print out here } else // all other cases { cout << setw(10) << left << iter -> first << iter-> second << endl; // print out any other characters here } // 9. set justification right // 10. display the percentage in fixed decimal format where decimal point is always shown // you will need to use showpoint and fixed double percent = ((iter -> second)/(user_text.size())); cout << showpoint <<setw(10) << right << percent; } // ask the user if they would like to enter another user_text cout << endl << "Would you like to enter more text (y/n): "; getline( cin, answer ); // if user presses enter key without inputting any text prompt user again while(answer.empty()) { cout << endl << "Invalid Answer - Would you like to enter more text (y/n): "; getline( cin, answer ); } } while ( answer.at(0) == 'y' || answer.at(0) == 'Y' ); return EXIT_SUCCESS; }

Explanation / Answer

NO ONE CAN UNDERSTAND YOUR THIS TYPE OF MIXED QUESTION, BE CONCISE AND RE POST

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote