Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C++ program to serve as the database for some number of students. The ma

ID: 3660760 • Letter: W

Question

Write a C++ program to serve as the database for some number of students. The maximum number of students in the database will be defined as a global variable in your program and can be changed to suit different number of students. You will read the students' information from an input file. On the first line of the input file, you will have the number of students. Each student will have the following information stored for him/her:

1) Last Name (ALL Fields will be represented as type string)
2) First Name
3) e-mail address
4) Street Address
5) City
6) State
7) Zip Code
8) Phone Number

Here is what your program will do:

a) populate the database, i.e., read the input file and store the data. You may use a class or a struct to store each student's data. Thus, to store the data for more than one student, you will need a vector (or array) of your Student struct or class, depending on the choice you have made.

b) Once you have stored the data in the vector, your program should provide the following options:
1) Display the list of all students with their information
2) Display the information for students with a requested last name, thus with this option, you will ask the user to input a last name.
3) Display all the users who have e-mail addresses with a requested provider, for example: aol.com. Thus, with this option, the user enters the provider's information, for example, aol.com.
4) Display all students with a requested area code, i.e. the user enters an area code with this option.
5) Display all students from a requested city, thus, the user provides a city name with this option.

A partial Student class and main program is provided below, which you may use to get started:

--------------------------------------------------------------------------------------------------------

#ifndef STUDENT_H

#define STUDENT_H


#include<fstream>

using namespace std;


class Student

{

public:

Student();

string getLastName() { return lastName; }

void setLastName(string val) { lastName = val; }

string setFirstName() { return firstName; }

void setFirstName(string val) { firstName = val; }

string getEmail() { return email; }

void setEmail(string val) { email = val; }


friend istream& operator>>(istream& ins, Student& s);

friend ostream& operator<<(ostream& outs, Student& s);


private:

string lastName;

string firstName;

string email;

};


#endif // STUDENT_H

-------------------------------------------------------------------------------------------------------------

// This program will ask for some values and display their average


#include<iostream>

#include<fstream>

#include<vector>

#include<cstdlib>

#include "Student.h"

using namespace std;


const int MAX_SIZE = 20; // default max size of database


void get_stream(ifstream& ins);


int main( )

{

int size, count;


vector<Student> dbase(MAX_SIZE);

Student tempStudent;

ifstream ins;


get_stream(ins);


ins >> size;

ins >> tempStudent;


cout << tempStudent;


return 0;

}



void get_stream(ifstream& ins)

{


ins.open("student.txt");

if(ins.fail())

{

cout << "Failed to open the input file. ";

exit(1);

}

}

Here is a sampleinput file:

Explanation / Answer

#include #include #include #include #include #include using namespace std; int main() { FILE *fp, *ft; char another, choice; struct student { char first_name[50], last_name[50]; char course[100]; int section; }; struct student e; char xfirst_name[50], xlast_name[50]; long int recsize; fp=fopen("users.txt","rb+"); if (fp == NULL) { fp = fopen("users.txt","wb+"); if (fp==NULL) { puts("Cannot open file"); return 0; } } recsize = sizeof(e); while(1) { system("cls"); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote