Thread: Lowest score drop assignment

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    15

    Lowest score drop assignment

    Hello everyone, I am having a problem to program this assignment. (I've looked in my C++ book and searched these boards and google other forums already, but nothing I've found explains that help me to solve the problem.) My problem is that after I input the getScores. I get a break or continue error and fail to build the program. I think the problem was the "findLowest" or "calcAverage" part in the code. Here is an error that I got: (error C3861: "findLowest": identifier not found.) I almost finish the assignment, but this error keeps failing me. I hope someone could explain the problem to me, and guide me how to work on this problem/error. Thank you, and I would really appreciate you very much.

    Here is the following assignment question:

    Write a program that calcuates the average of a group of 5 test scores, where the lowest score in the group is dropped. Your program should use the following functions:

    • getScore( ) should ask the user for a test score, store it in a reference variable, and validate it. This function should be called by main once for each of the five scores.
    • calcAverage( ) should calculate and display the average of the four highest scores. This function should be called just once by main, and should be passed the five scores.
    • findLowest( ) should find and return the lowest of the five scores passed to it. It should be called by cacAverage, which uses the function to determin which of the five scores to drop.

    Input Validation: Do not accept test scores lower than 0 or higher than 100


    And here is the code:


    Code:
    .
    #include <iostream>
    #include <iomanip>
    using namespace std;
     
    // Function prototype
    void getScore(int &);
    void calcAverage(int, int, int, int, int);
    int fineLowest(int, int, int, int, int);
            
    int main()
    {
             int testScr1, testScr2, testScr3, testScr4, testScr5;
            
            
             getScore(testScr1);
             getScore(testScr2);
             getScore(testScr3);
             getScore(testScr4);
             getScore(testScr5);
     
             calcAverage(testScr1, testScr2, testScr3, testScr4, testScr5);
     
     
    system("PAUSE");
    return 0;
    }
     
    //********************************************
    //Definition of function getScore                                     *
    //This function displays a message.                                 *
    //********************************************
    void getScore(int &score)
    {
             cout << "Enter a test score\n";
             cin >> score;
            
             while (score < 0 || score > 100)
             {
                      cout << "Please enter a valid test score that between 0 to 100\n";
                      cin >> score;
             }
     
    }
     
     
    //*******************************************
    //Definition of function calcAverage                             *
    //This function displays a message.                               *
    //*******************************************
    void calcAverage(int s1, int s2, int s3, int s4, int s5)
    {
             int sum;
             int      lowest;
             double average;
            
            
             lowest = findLowest(s1, s2, s3, s4, s5);
     
             sum = s1 + s2 + s3 + s4 + s5 - lowest;
             average = sum/4.0;
            
             cout << setw(4) << fixed << showpoint << setprecision(2);
             cout << "The avergae of the four highest scores are: " << average << endl;
    }
     
     
    //*******************************************
    //Definition of function findLowest                               *
    //This function displays a message.                               *
    //*******************************************
    int findLowest(int s1, int s2, int s3, int s4, int s5)
    {
             int lowest = s1; 
            
            
        if (s2 < lowest )        
             {
                      lowest = s2;
             }
             else if (s3 < lowest)
             {
                      lowest = s3;
             }
             else if (s4 < lowest)
        {
                      lowest = s4;
             }
             else if (s5 < lowest)
             {
                      lowest = s5;
             }
     
             cout << "The lowest test score is: " << lowest << endl;
     
        return lowest;
    }
    .

    (P.s. I am a newcomer to this website, and also a newbie in c++ programming field.)
    Last edited by inobProgram; 07-03-2012 at 11:41 PM.

  2. #2
    Registered User
    Join Date
    Dec 2005
    Posts
    136
    fineLowest.. Lowest is fine instead of find
    S_ccess is waiting for u. Go Ahead, put u there.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Remove all the else's from findLowest.

    Something like
    Code:
             if (s2 < lowest )       
             {
                      lowest = s2;
             }
             if (s3 < lowest)
             {
                      lowest = s3;
             }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Jul 2012
    Posts
    15
    Hi Salem, thanks for your response to help me on this assignment, and sorry for the late reply. But I still got the same error (error C3861: "findLowest": identifier not found.) after I remove the else's.

  5. #5
    Registered User
    Join Date
    Jul 2012
    Posts
    15
    mistake English, and thanks anyway.

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Prototype:
    int fineLowest(int, int, int, int, int);

    Definition:
    int findLowest(int s1, int s2, int s3, int s4, int s5)

    And while you're at it, read: SourceForge.net: Do not remove parameter names - cpwiki
    Learning how to use arrays and loops wouldn't be a bad idea, either.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    Registered User
    Join Date
    Jul 2012
    Posts
    15
    Quote Originally Posted by maven View Post
    fineLowest.. Lowest is fine instead of find
    YOU SAVE MY TIME [maven], and now the program works perfectly.

  8. #8
    Registered User
    Join Date
    Jul 2012
    Posts
    15
    Hi Elysia, thanks for your response. I just noticed that spelling error....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with Lowest Score drop program.
    By soupcan in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2012, 09:59 PM
  2. Drop lowest score?
    By unknownnoob in forum C++ Programming
    Replies: 4
    Last Post: 09-23-2010, 02:27 PM
  3. Replies: 22
    Last Post: 11-13-2009, 05:51 PM
  4. Lowest Score Drop - C++
    By getName(C-Dub) in forum C++ Programming
    Replies: 4
    Last Post: 01-20-2008, 07:02 PM
  5. Lowest Score Drop
    By naya22 in forum C++ Programming
    Replies: 16
    Last Post: 04-29-2007, 12:48 AM

Tags for this Thread