I have an array of numbers and i have to find lowest and highest and drop them. When i display the numbers on my output screen it has to display HIGH for highest and LOW for lowest instead of the actual numbers. this is an int array so clearly i cant store a string there.Help would be appreciated.

this is how im trying to display

Final = Total(all numbers together)  - Low(lowest #) - High(Highest #);

   cout << "judge 1: " << Numbers[0];
   cout << "judge 2: " << Numbers[1];
   cout << "judge 3: " << Numbers[2];
   cout << "judge 4: " << Numbers[3];
   cout << "judge 5: " << Numbers[4];
   cout << "Total: " << Final;

please help

.

Find the min/max as you normally would, then store the indexes of the low/high values, in addition to the values themselves. You would then modify your output stream based on the current index rather than the actual value. If your current index for your output matches either stored index, you output the appropriate message.

EDIT:
>>anyone?
Dude!!! It hasn't even been an hour. It's an online forum, people answer what they can when they can. It is unreasonable to expect immediate responses.

im not a really good programmer so could you possibly show me an example? i mean i know how to get low and high but what to do after is my problem..storing them and modifying like you said.

for ( int k = 0; k < MAX_SCORES; k++)
      {
      if (Numbers[k] < Low)
         Low = Numbers[k];
         //how else would i store them?
       if (Numbers[k] > High)
          High = Numbers[k];

can anyone help i need this done :/

commented: Stop being so impatient. And don't bump threads. -1

>>im not a really good programmer...
Then quit being so impatient and practice, it's the only way to get "really good". Take the time to think things through, use a pen and paper if you have to.

This really isn't that difficult of a situation. You're already storing the indexes temporarily, how else would you be able to access them sequentially. You just need to find a way to store them on a more "permanent" basis. To do that, take your code then add 2 variables; add one for the low index and another for the high index. You would then store the current index into the appropriate one when you detect a new min/max value.

You would then use if statements to control your output statement's contents. The conditions in the ifs would be based on equality comparisons that use the currentIndex and the min/max indexes.

//declarations:
int currentMin = array[0], currentMax = array[0];
int minIndex = 0, maxIndex = 0;

//find min and max
for (int i = 1; i < SIZE; ++i) {
  if (array[i] < currentMin) {
    currentMin = array[i];
    minIndex = i;
  } else if (  // ...max comparison) {
    // ...
  }
  // ...
}

//display
for (int j = 0; j < SIZE; ++j) {
  cout << "judge " << (j+1) << ": ";
  if (//min index detection) {
    //min output
  } else if (//max index detection) {
    //max output
  } else { //non-min/max
    cout << array[j] << endl;
}

I know you're going to ask, so before you do; yes, it is possible to expand on this for your calculation of the total score. It only requires a little expanding, but you should be able to handle simple arithmetic on your own.

well i just need to finish this semester. C++ isnt my thing. im impatient because i spent 2 days on this little thing. and now its going to be late :/
but umm this is what i got? its wrong because it doesnt work but i think im on my way?

for ( int J =0; J < MAX_SCORES; J++)
          cout << "judge " << (J+1) << ": ";
          if ( Numbers[J] = Low)
             cout << "Judge" << (J+1) << "Low";
          else if ( Numbers[J] = High)
             cout << "Judge" << (J+1) << "High";
          else
              cout << Numbers[J];

Well, I can see a collection of issues:
First, for equality comparisons, you need to use the double-equal operator (==), not the single-equal (=) operator, which is assignment. Writing an assignment statement here is a cardinal sin and a massive logic error.

Second, overlooking the operator error, you have the right idea, but you're using the wrong variables. What would happen if more than one judge issued the same maximum (or minimum) score? Your results would get skewed by repetitive exclusion. Instead of only excluding 2 scores, you may exclude 3 creating invalid results. Your if statements should be based on the actual indexes, not the values of the elements. i.e. if (j == minIndex) Third, you need to set up your for loop's statement block correctly. Right now, Line 3 is the only Line that is part of your loop. Have another look at the "display" part of my example (reposted and partially updated below). Pay particular attention to how I used the curly braces and what sections of the output are included where.

//display
for (int j = 0; j < SIZE; ++j) {
  cout << "judge " << (j+1) << ": ";
  if (j == minIndex) {                //if this is the minimum index
    cout << "Minimum"
  } else if (//max index detection) { //if this is the maximum index
    //max output
  } else {                            //if this is neither the min nor max
    cout << array[j];
  }
  cout << endl;
}

oh right i forgot about curly braces. I feel really stupid. i dont think u understand my full requirements. I need to output which judge, what was his number, and if its too high i have to display judge (whatever # he is out of 5) and then HIGH. same for LOW. what do u mean by minindex?

Thank you so much for help. i got it now with your help. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.