LNK2019 неразрешенный внешний символ "int __cdecl excAvg (void)" - PullRequest
0 голосов
/ 11 июля 2020

Когда я пытаюсь скомпилировать, я получаю только два сообщения об ошибках.

"Ошибка LNK2019 неразрешенный внешний символ" int __cdecl excAvg (void) "(? ExcAvg @@ YAHXZ), на который ссылается функция _main

Строка 1

и

LNK1120 1 неразрешенные внешние

также в Строке 1

Я работал над этим так долго (дней), что действительно не могу понять, где я ошибаюсь, я уверен, что это что-то простое, но я снова в проигрыше.

Кто-нибудь, пожалуйста дать мне предложение помочь исправить коды ошибок?

/*
    Christopher Pierce

Date Created: July 3, 2020

Egrades Vector Application

*This application creates a C++ menu program that generates an electronic grade sheet that can keep track of five student test scores earned during the semester.

• Organizes the main program menu to call four functions.
• (1) function that allow a user to Add five students and their scores on three exams into the vector.
• (2) function that will compute the average test score for each of the five students in the vector.
• (3) function that all the user to display a student average test scores searching for their name in the vector.
• (4) function that will compute the average of the average exams in the vector and display the result.
*/

#include <iostream>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

// Declarations

int score1;
int score2;
int score3;
int score4;
int score5;
int score6;
int score7;
int score8;
int score9;
int score10;
int score11;
int score12;
int score13;
int score14;
int score15;

string student1;
string student2;
string student3;
string student4;
string student5;

int main()

{

    vector <string> StudentFile;
    vector <int> Egrades;


    int average1 = (score1 + score2 + score3) / 3;
    int average2 = (score4 + score5 + score6) / 3;
    int average3 = (score7 + score8 + score9) / 3;
    int average4 = (score10 + score11 + score12) / 3;
    int average5 = (score13 + score14 + score15) / 3;

    // Prototype (functions)

    int examAvg();
    {
        StudentFile.insert(StudentFile.begin(), student1);
        Egrades.insert(Egrades.begin(), average1);

        StudentFile.push_back(student2);
        Egrades.push_back(average2);

        StudentFile.push_back(student3);
        Egrades.push_back(average3);

        StudentFile.push_back(student4);
        Egrades.push_back(average4);

        StudentFile.push_back(student5);
        Egrades.push_back(average5);
    }
    /*
    

    Start of Menu
    

    */
     
    // Defines the width of the menu
    const int menuWidth = 84;

    // This is a loop structure for the menu box using ASCII
    // This prints the top left corner of the menu box (ASCII)
    cout << char(201);

    // This prints the top border of the menu box (ASCII)
    for (int column = 0; column < menuWidth; ++column) {
        cout << char(205);
    }

    // This prints the top right corner of the menu box (ASCII)
    cout << char(187);
    cout << "\n";

    // array with menu options
    string menu[15];
    menu[0] = "                                 **************";
    menu[1] = "                              ***  MAIN  MENU  ***";
    menu[2] = "                                 **************";
    menu[3] = "                    Please Choose From The Following Options:";
    menu[6] = "  1. Add 5 Students to Egrades Vector:";
    menu[8] = "  2. Compute Student Test Score Average:";
    menu[10] = "  3. Search A Student Average Test Score:";
    menu[12] = "  4. Compute The Average Of All 5 Student Exam Averages:";
    menu[14] = "  5. Exit";


    for (string option : menu)
    {
        cout << char(186) // print left border
            << setw(menuWidth) // set next item width
            << left // set next item aligment
            << option // print menu option string with width and aligment
            << char(186) << "\n"; // print right border
    }

    // This will print the bottom left corner of the menu box (ASCII)
    cout << char(200);

    // This prints the bottom border of the menu box (ASCII)
    for (int column = 0; column < menuWidth; ++column) {
        cout << char(205);
    }

    // This prints the bottom right corner of the menu box (ASCII)
    cout << char(188);
    cout << "\n\n";

    /*


    END OF MENU


     */

    char selection;

    cout << "\t\t\t     Enter Your Selection: ", cin >> selection, cout << endl;

        switch (selection)

        {

        case '1':

            system("CLS");

                    cout << "Student Information Section:\n\n";

                    // Student 1 Info, captures name and scores        

                    cout << "\nEnter Student 1 Name: \n";

                    cin >> student1;

                    cout << "\nEnter Exam 1 Score: ";
                    cin >> score1;
                    cout << "Enter Exam 2 Score: ";
                    cin >> score2;
                    cout << "Enter Exam 3 Score: ";
                    cin >> score3; examAvg();

                    // Student 2 Info, captures name and scores        

                    cout << "\nEnter Student 2 Name:\n";

                    cin >> student2;

                    cout << "\nEnter Exam 1 Score: ";
                    cin >> score4;
                    cout << "Enter Exam 2 Score: ";
                    cin >> score5;
                    cout << "Enter Exam 3 Score: ";
                    cin >> score6; examAvg();

                    // Student 3 Info, captures name and scores        

                    cout << "\nEnter Student 3 Name:\n";

                    cin >> student3;

                    cout << "\nEnter Exam 1 Score: ";
                    cin >> score7;
                    cout << "Enter Exam 2 Score: ";
                    cin >> score8;
                    cout << "Enter Exam 3 Score: ";
                    cin >> score9; examAvg();

                    // Student 4 Info, captures name and scores        

                    cout << "\nEnter Student 4 Name:\n";

                    cin >> student4;

                    cout << "\nEnter Exam 1 Score: ";
                    cin >> score10;
                    cout << "Enter Exam 2 Score: ";
                    cin >> score11;
                    cout << "Enter Exam 3 Score: ";
                    cin >> score12; examAvg();

                    // Student 5 Info, captures name and scores        

                    cout << "\nEnter Student 5 Name:\n";

                    cin >> student5;

                    cout << "\nEnter Exam 1 Score: ";
                    cin >> score13;
                    cout << "Enter Exam 2 Score: ";
                    cin >> score14;
                    cout << "Enter Exam 3 Score: ";
                    cin >> score15; examAvg();
                  
                
                cout << "\n\n******************************************************\n";
                cout << "!!!  INFORMATION HAS BEEN ADDED TO EGRADES VECTOR  !!!\n";
                cout << "******************************************************\n\n";
                cout << "To Return To Main Menu:\n\n";
                system("pause");

                    return main(); 

            break;
                
        case '2':

            system("CLS");

            
            for (unsigned int i = 0; i < Egrades.size(); ++i)
            {
                cout << Egrades[i] << endl;
            }
            
            cout << "To Return To Main Menu:\n\n";
            system("pause");
            return main();

                break;
            

        case '3':

            system("CLS");

            int score;
            cout << "\nEnter A Students Name To Find Their Average:\n";
            cin >> score;

            if (cin >> student1)

            {
                cout << "Average Found:\n" << average1;
            }
            else if (cin >> student2)
            {
            
                cout << "Average Found:\n" << average2;
            
            }
            else if (cin >> student3)
            {
                
                cout << "Average Found:\n" << average3;

            }
            else if (cin >> student4)
            {

                cout << "Average Found:\n" << average4;

            }
            else if (cin >> student5)
            {

                cout << "Average Found:\n" << average5;

            }
            else
            {
                cout << "Average not found.\n";
            }

            cout << "To Return To Main Menu:\n\n";
            system("pause");
            return main();

            break;

        case '4':

            system("CLS");

            cout << "The Average of All Five Students Averages Are:\n\n";
            cout << "||  " << (average1 + average2 + average3 + average4 + average5) / 5 << "  ||\n\n";

            cout << "To Return To Main Menu:\n\n";
            system("pause");
            return main();

            break;

        case '5':

            exit(-1);

            break;

        default: cout << "\n Invalid selection\n\n";

        }

    return 0;

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...