Solved

average using the 4 highest scores of the 5 enterd

Posted on 2003-11-24
10
336 Views
Last Modified: 2010-04-01
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
  • 3
  • 2
  • 2
  • +2
10 Comments
 

Author Comment

by:tbell000
ID: 9815835
thanks for your help yesterday hope you can help today
also i have not accepted any ones answers
so all the points are your if you are correct
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9815883
tbel000, I don't understand why you now have 3 questions asking about the same problem. Please keep working with the other experts who helped you in the last 2 threads and get things straightened out. They also need to receive credits for helping you as well. Please close two of these open questions as I suggested in the other thread.
0
 
LVL 4

Expert Comment

by:n_fortynine
ID: 9815886
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 24

Accepted Solution

by:
shivsa earned 500 total points
ID: 9815889
#include <iostream>
#include <iomanip>
using namespace std;

void EvalGrade ( int Grade);
int Minimum(int test1, int test2 , int test3, int test4, int test5);

void EvalGrade(int Grade)
{
  char letterGrade;

   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; }

int  Minimum(int test1,int test2,int  test3,int  test4, int 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;
}

int main()
 {

  int Grade;
        int test1, test2, test3, test4, test5;
        float Ave;
        int min;

   cout <<"Please enter Test 1\n ";
   cin >> test1;
   EvalGrade ( test1);
   cout << "Please enter Test 2\n";
   cin >> test2;
   EvalGrade ( test2);
   cout << "Please enter Test 3\n";
   cin >> test3;
   EvalGrade ( test3);
   cout << "Please enter Test 4\n";
   cin >> test4;
   EvalGrade ( test4);
   cout << "Please enter Test 5\n";
   cin >> test5;
    EvalGrade ( test5);
        min = Minimum(test1,test2,test3,test4,test5);  
     Ave =(float)((test1 + test2+ test3 +test4 + test5 - min) / 4);
       
   cout << "The Average is : " << Ave << endl;
       

}
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9815928
correction change last 3 lines with this. aftre min = Minimum(......);

Ave =(float)(test1 + test2+ test3 +test4 + test5 - min) /((float) 4);
        cout.setf(ios::showpoint);
   cout << "The Average is : " << Ave << endl;
0
 
LVL 24

Expert Comment

by:shivsa
ID: 9815939
please let us know if u have more questions.
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 9816026
here's a real nice way to do it. you won't beleive how short this thing is.

#include <vector>
#include <algorithm>
#include <numeric>

...

int main()
{
    float tmp;
    vector<float> grades = new vector();

    for(int i = 1; i < 6; i++)
    {
        cout << "Please enter Test " << i << "\n";
        cin >> tmp;
        grades.push_back(tmp);
    }

    float total = accumulate(grades.begin(), grades.end(), 0);
    float minimum = min_element(grades.begin(), grades.end());

    float average = (total - minimum) / 4.0;
}
0
 
LVL 3

Expert Comment

by:monkesdb
ID: 9816034
add a

using namespace std;

in there (i always forget before i compile it the first time)
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10285810
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: shivsa {http:#9815889}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 …
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 goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

739 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