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

ou will use std::map to find the mode of a set of numbers. You will first use st

ID: 653914 • Letter: O

Question

ou will use std::map to find the mode of a set of numbers.

You will first use std::cin to input numbers as we have done in our earlier labs. These numbers should be inserted into a std::map. The numbers should be the key in your map and the values associated with your keys will be the count for each number.

Once all the numbers have been input into your map, the counts should have automatically been updated. You can then iterate through your key-value pairs in your map and find the maximum count. This will be your mode.

Here is a sample run of an example solution:

./mode
Please enter your numbers
1 2 2 3 3 3 4 5 6 7 7 8 8 8 8 9 d
The mode is 8

Explanation / Answer

#include "StdAfx.h"
#include <iostream>

using namespace std;


int main()
{

       int user;
       int x = 0;
       float mean;
       float median;
       int mode;
       int range;
   do {
       cout << "please enter any number other than 5: ";
          
           cin >> user;
           x++;
           for (int i = 0; i < 10; i++);
           cout << "you enter " << user << endl;
          
          
   } while (user != 5 && x < 10); {

       if (user == 5) {
              cout << "Hey! you were'nt suppose to enter that: . ";
              
               user = user + user;
               mean = user / x + 1;
               cout << "your mean is: " << mean << endl; // this is where i start having the problem start //
              
                   median = user / x + 1;
                   if ( user % 2 == 0 || user % 2 != 0 )
               cout << " your median is : " << median << endl;

              
              
           }
       else {
          
           cout << "wow you are more patient than me u win ";

           user = user + user;
               mean = user / x + 1;
               cout << "your mean is: " << mean << endl;
              
               median = user / x + 1;
                   if ( user % 2 == 0 || user % 2 != 0 )
               cout << " your median is : " << median << endl;

                  


      
       }
   }

   system ("pause");


return 0;
}