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

i made a c++ program that took in imformation using getline and placed it into v

ID: 3542954 • Letter: I

Question

i made a c++ program that took in imformation using getline and placed it into vectors.  I did some calullations of data; this I also put into vectore.  Im a student so of course i dont get understand everrything perfectly but i hope im explaining well enough...  There are only three vector types being used. the first vector was a string which held a name and id number.  The Others where doubles and a char.    In the revision; whiich is what im wirjking on right now,  i have to create functions in order to make the program modular.   The first is to get the input, (which will be feed into a vector due to it being a program that takes more than one persons data and peocesses it.).  Question is:  since i have these types of input can i make one function that not only getline(cin, whatwverthevalueis);  but one that takes in the value and proceeds to return that value to be used in any immedeate calculations And manage to pushback the vector it goes into from the FUNCTION??  

Explanation / Answer

I think i posted solution you wanted this is the one i posted in othe question also if you meant the sme in both this is the perfect solution if not please ask me out ...

Please rate me high



#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <fstream> //to read and write file
#include <cctype>

using namespace std;



int main()
{

ifstream inputFile;
string password;
string studentList;
int i, index;
vector<string> vectStudentList;

cout << "Please enter the password for the text file: ";
getline (cin, password);

inputFile.open(password.c_str( ));



if (inputFile.fail())
{
for (i =3 ; i >0; i--)
{

cout << " Error for Opening File. " << endl;
cout << "You have up to"<< i <<"times to enter the right password!" << endl;

cout << " Please enter the password for the text file again: ";
getline (cin, password); //validation 2- loop that allows user 3 times to enter password
inputFile.open(password.c_str( ));
if (inputFile.fail()&&i==1){
cout << " entered wrong password for the text file !! access denied : ";
exit (0);}
if(!inputFile.fail()) break;
}
cout << " entered correct password for the text file !! access granted : ";
}

string studentList;
while (getline(inputFile, studentList))
{
vectStudentList.push_back (studentList);
}
cout << " The External Student List has the size of: " << vectStudentList.size() / 4 << endl << endl;

cout << left << setw (20) << "First Name" << setw (20) << "Last Name" << setw (20) << "ID" << setw (20) << "Enrolled Class" << endl << endl;
cout << "----------------------------- ------------------------------ ----------------" << endl;

for (int index = 0; index < vectStudentList.size(); index++)
{
cout << left << setw (20) << vectStudentList[index] << setw (20) << setw (20) << setw (20);
}