Thread: I am lost, please help!!!!!!!!!!!!!!

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    5

    I am lost, please help!!!!!!!!!!!!!!

    I really don't know where to began with this assignment. I have to calculae the average of a series of test scores where the lowest score in the series is dropped.

    1. GetVaules should ask for fiv test scores and store them in variables.

    2. Findlowest should determine which of the five scores is the lowest, and return that vaule.
    3. CalcAverage should calculate and display the average of the four highest scores. Not accepting scores greaten that 100 or less than 0. In put Five test scores.

    I did 2 out of 3, I don't know how to calcavg. Hopefully I did the first 2 right. PLEASE HELP. Here is my code::

    P.s. Remeber I am a BEGINNER!!!


    #include <iostream.h>

    void main ()
    {
    "function protype";
    void Getvalues (double scores);
    int findlowest();
    int calcaverage();
    }


    void Getvalues()
    {

    int score 1, score 2, score 3, score 4, score 5;
    cout<<"Please enter five test scores."<<end1;
    cin>>score 1>> score 2>> score 3>> score 4>> score 5;

    }

    int findlowest ()
    {
    if (score 1, score 2, score 3, score 4, score 5 > = 100)
    lowestscore = < 0;

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    200
    In the future, please use code tags.
    1. GetVaules should ask for fiv test scores and store them in variables.
    It is probably better to use an array for this like so
    Code:
    int scores[5];
    cout<<"please enter the values"<<endl;
    for (int i=0;i<5;i++){
         cin>>scores[i];
    }
    Code:
    int findlowest () 
    { 
    if (score 1, score 2, score 3, score 4, score 5 > = 100) 
    lowestscore = < 0;
    This will not work for several reasons. Try something like this:
    Code:
    int lowest=scores[0];
    for (int i=1;i<5;i++){
         if (scores[i]<lowest) lowest=scores[i];
    }
    to average a number of values, just add them up and divide by the number of values.

    I hope this helps. The code I gave you probably has some syntax errors in there somewhere, but they are probably easy to fix (I'm kinda tired)

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    317
    You might want to make Values global(aka defined outside any function) otherwise your other functions won't be able to reference them.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    559

    Re: I am lost, please help!!!!!!!!!!!!!!

    Originally posted by Cnote


    Code:
    #include <iostream.h>
    
    void main ()      // Should be int main
    {
    "function protype";     // This has no meaning and is an error
                                       // What you probably mean is // function prototype
    void Getvalues (double scores);     // Either declare the prototypes before main or code the whole function before main
    int findlowest();
    int calcaverage();
    }
    
    
    void Getvalues()
    {
    
    int score 1, score 2, score 3, score 4, score 5;
    cout<<"Please enter five test scores."<<end1;
    cin>>score 1>> score 2>> score 3>> score 4>> score 5;
    
    }
    
    int findlowest ()
    {
    	if (score 1, score 2, score 3, score 4,  score 5 > = 100)
    		lowestscore = < 0;
    Other stuff like fyodor says.
    Truth is a malleable commodity - Dick Cheney

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    5
    Thank you sooo much. That was a great help! Now, the way I int calcuavg, values and findlowest was ok, I take it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. The getting lost and walking in circles
    By Mario F. in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 05-07-2008, 09:53 AM
  2. I lost my laptop, DVD and money
    By Sang-drax in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 10-01-2004, 07:13 PM
  3. lost disk
    By Benzakhar in forum Linux Programming
    Replies: 7
    Last Post: 01-11-2004, 06:18 PM
  4. Lost ID number
    By ripper079 in forum C++ Programming
    Replies: 13
    Last Post: 10-04-2002, 12:51 PM
  5. API, LOST... help
    By Unregistered in forum Windows Programming
    Replies: 5
    Last Post: 03-13-2002, 03:19 PM