?
Solved

using a funtion to find the average of test scores

Posted on 2003-11-23
2
Medium Priority
?
329 Views
Last Modified: 2010-04-02
i need help to find the averge of the 4 highest test scores
out of the 5 that were entered i think i need a func but i'm having trouble setting it  up..

#include <iostream>
#include <iomanip>
using namespace std;


void EvalGrade ( int Grade);
void FindAve (float Ave);
void Minimum(float,float,float,float,float);
{
  char letterGrade;
please email me a911hoe@msn.com with answ
 

   switch ( Grade/10)
   {
      case 10:
        case 9:
           
              letterGrade = 'A';
                break;

        case 8:
                 letterGrade = 'B';
                 break;

        case 7:
                letterGrade = 'C';
                break;

        case 6:
                letterGrade = 'D';
                break;

        case 5:
        case 4:
        case 3:
        case 2:
        case 1:
        case 0:
                letterGrade = 'F';



   }

   cout << "The letter grade is: " << letterGrade << endl;
   cout << "The Average is :" << ave << endl;
}

void main()

 {

      float Minimum(float test1,float test2, float test3, float test4, float test5)

          if (test1 < test2 && test1 < test5)
                   return test1;
            if (test2 < test1 && test2 < test5)
                  return test2;
            if (test3 < test1 && test3 < test5)
                  return test3;
            if (test4 < test1 && test4 < test5)
                  return test4;
            if (test5 < test1 && test5 <test4)
                  return test5;

       FindAve

         Ave = test1 + test2+ test3 +test4 + test5 - Minimum / 4;
      
      return Ave


  int Grade;

   cout <<"Please enter Test 1\n ";
   cin >> Grade;

   EvalGrade ( Grade);

   cout << "Please enter Test 2\n";
   cin >> Grade;

   EvalGrade ( Grade);

   cout << "Please enter Test 3\n";
   cin >> Grade;

   EvalGrade ( Grade);

   cout << "Please enter Test 4\n";
   cin >> Grade;

   EvalGrade ( Grade);

   cout << "Please enter Test 5\n";
   cin >> Grade;

    EvalGrade ( Grade);
 


}
 
0
Comment
Question by:tbell000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Assisted Solution

by:n_fortynine
n_fortynine earned 1000 total points
ID: 9808852
tbell000, you're posting the same question twice. You can post a message to Community Support and ask them to close this one question and refund the points.
http://www.experts-exchange.com/Community_Support/
0
 
LVL 3

Accepted Solution

by:
RJSoft earned 1000 total points
ID: 9811518
Sounds like you need a bubble sort to order the grades highest to lowest and then use the first 5 grades.

That way you can enter as many as you like and only then average the best 4 or however many you wish to see.

This is an old routine for sorting most occuring lotto numbers.
MOSTLOTTO is a structure that holds the numbers 1 to 53 and
the amount of times shown for each of the numbers.

struct LOTTO
{
char NumberString[10]; // 1 to 53 for displaying
int   Num; // amount of times shown.
};

LOTTO MOSTLOTTO[10000];

//some other function to read values into MOSTLOTTO
LoadMostLotto();

//bubble sort
void SortMOST(int end)
{
int top, search, temp;
for(top=0;top < end-1;top++)  
for(search=top+1;search < end;search++)  
if(MOSTLOTTO[search].Num > MOSTLOTTO[top].Num)
{
 temp = MOSTLOTTO[search].Num;
 MOSTLOTTO[search].Num = MOSTLOTTO[top].Num;
  MOSTLOTTO[top].Num = temp;
}// end if
}// end for
}// end func


So now if I wanted to I could use only the first 4 elements of MOSTLOTTO to do an average on.

int LottoAverage = (
MOSTLOTTO[0].Num +
MOSTLOTTO[1].Num +
MOSTLOTTO[2].Num +
MOSTLOTTO[0].Num) / 4;



So now your logic would go

(semi pseudo code)

struct YOUSTRUCT
{
....
....
};

YOUSTRUCT YOU[YOURMAX];

begin func
{
begin outer loop
{
clear screen;
Prompt menu "(L)oad, (A)verage, e(X)it"

if(L)
loop
{
YOU[x].Val1=xxxxx;
YOU[x].Val2=yyyyy;
x++;
prompt (exit) break;
}//endifL

if(A)
{
prompt how many >> in
int val=0;
int x=0;
adding loop
{
add from YOU[x].yyy or xx to val ,then x++ untill x== in
}//end adding loop
answer = val / in;
}//endif A

if(X)break;

}//end outer loop

}//endfunc

RJSoft
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question