// This program will display the list of students in a class, names ranging from 5-30, display the name entered
// and arrange the first and last student in a line by alphabetizing the first names.
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
// Display the number of student in the class.
cout << "How many students are in the class?";
cin >> students;
fflush(stdin);
// Input validation
while (students < MIN_STUDENTS || students > MAX_STUDENTS )
{
// input error.
cout << "ERROR: must have at least 5 studeunts"<<endl;
// Input again.
cout << "How many students are in the class?\n "<<endl;
cin >> students;
fflush(stdin);
}
string name;
string firstname;
string lastname;
ifstream infile;
ofstream outfile;
outfile.open("out.txt");
//enter the name of the students.
for(int students=1;students<=30;students++)
{
cout << "Enter the name of the students:";
getline(cin,name,'\n');
fflush(stdin);
}
// Display the student at the front and the back of the line.
{
if (firstname>lastname)
cout << firstname<<endl<<lastname<<endl;
else
cout << lastname<<endl<<firstname<<endl;
cout << name << "would be in the front of the line\n"<<endl;
cout << name << "would be at the back of the line\n"<<endl;
}
while(again=='y')
{
cout << "\nRun again (y/n)?";
cin >> again;
fflush(stdin);
}
cout << "Programmer: Shane Modeste\n";
system ("pause");
return 0;