Thread: unexpected end of file error?

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    12

    unexpected end of file error?

    Can someone tell me why I am getting an unexpected end of file error?

    [code]

    //This program collects 5 exam score for individual class members and averages the score.
    //The program throws out the low score and replaces it with the high score.
    //It uses a sentinel to end the input data.

    #include <iostream>
    #include <iomanip>
    #include <string>

    using namespace std;
    int main()

    {
    int array[5];
    int y;
    int highScore=-999;
    int lowScore=101;
    int totScore=0.0;
    float avg=0.0;
    char grade;

    string firstName;
    string lastName;
    string sentinelA="light";
    string sentinelB="truth";

    cout << "Enter student's first and last name:" << endl;
    cin >> firstName >> lastName;

    cout << "To stop input data, enter light for student's first name,";
    cout << "and truth for student's last name." << endl;

    while (firstName != sentinelA && lastName != sentinelB) //Creates input data stopping point.

    {
    cout << "Enter 5 exam scores for" << firstName << lastName << ":" << endl; //input exam scores

    for (y=0; y<5; y++)
    {
    cin >> array[y];
    }

    for (y=0; y<5; y++);
    {
    if(array[y] > highScore)
    highScore = array[y];

    if(array[y] < lowScore)
    lowScore = array[y];
    }

    for (y=0; y<5; y++) //Throws out the low score and replaces it with the high score.
    {
    if(array[y] == lowScore)
    array[y] = highScore;
    }

    for(y=0; y<5; y++)
    {
    totScore = totScore + array[y];
    }

    {
    avg = totScore/5; //Determines average grade.

    if(avg > 92.0) //Determines letter grade.
    grade='A';
    else if (avg > 83.0)
    grade='B';
    else if(avg > 74.0)
    grade='C';
    else if(avg >65.0)
    grade='D';
    else
    grade='F';
    }

    cout << "The 5 exam scores for" << firstName << " " << lastName << ":" << endl;
    cout << endl;

    for (y=0; y<5; y++)
    cout << array[y] << " ";
    cout << "The average score for" << firstName << " " << lastName << endl;
    cout << "is" <<avg << "%" << "Letter grade is" << grade <<endl << endl;

    cout << "Enter the next student's name and exam scores" << endl;
    cin >> firstName >> lastName;

    {
    avg = 0.0;
    totScore = 0.0;

    }
    return 0;
    }

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Please use code tags.

    Unexpected end of file on compilation usually means your braces are bork, so properly indented code will not only let us read it, but usually handle brace mismatches.

  3. #3
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    your missing and ending bracket '}'.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM
  3. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM