Final answer:
The student's question about writing a C++ program to display NCAA College Football Champions by year involves using object-oriented principles to read from a file, store the data in arrays, and respond to user queries. The provided outline demonstrates how one might structure such a program using a ChampionDatabase class and a main function that manages user interaction.
Step-by-step explanation:
The student requested help with writing a C++ program that displays the National Champion of NCAA College Football for a year entered by the user. This program relies on object-oriented principles and file I/O operations to function correctly.
The years range from 1998 to 2022. In response to this request, an example of such a program is presented here. The program reads the champion data from 'NationalChampionship.txt', stores it in arrays, allows the user to query the data by entering a year, and continues to prompt for years until the user decides to stop. Below is a potential implementation skeleton that fulfills the requirements:
#include
#include
#include
class ChampionDatabase {
private:
int years[25];
std::string teams[25];
public:
ChampionDatabase() { /* Read file and populate arrays */ }
std::string GetChampion(int year) { /* Return the champion for the given year */ }
// ... additional methods as appropriate ...
};
int main() {
ChampionDatabase db;
int year;
std::string input;
std::string champion;
do {
std::cout << "Enter the year to find the National Champion (1998-2022), or type 'quit' to exit: ";
std::cin >> input;
if (input == "quit") break;
// Input validation and querying logic here...
} while (true);
return 0;
}
Notice that the ChampionDatabase class is responsible for reading from the input file and providing a method to lookup the champion given a year.
The main function handles the user interaction. This is only the skeleton of the program, and further implementation of reading the file, populating the arrays, handling input validation, and providing output would be required for a full solution.