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

C++ Problem A: Looking through data (20 points) Download peopleData.txt and look

ID: 3676990 • Letter: C

Question

C++

Problem A: Looking through data (20 points)
Download peopleData.txt and look through it (you can also rename it peopleData.csv to open in excel
or some spreadsheet app). Write a program that reads this file then finds and displays on the username
and password, if that line has one in the format “[username] : [password]”. This should be repeated
until the end of the file (without displaying the last one twice!).
You cannot assume the username will always be in the same place (or that it exists for a person at all).
You may assume that if there is a username, then there will be a password (but again, you should not
assume where it is located in the line). You do not need to check and see if the file properly exists here.
Example 1 (generated from peopleData.txt):
Herch1955 : ahg7aa9Kei
Ardsomal : aiCoh6Chi
Felich : eiHee3ie
Therstion : AeTai9ien3ie
Wittiptacked : ha8Thufah
Hisaim : Oocaing8

peopleData.txt:

Explanation / Answer

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string.h>
#include <cstdlib>
using namespace std;


int main()
{
ifstream file_("peopleData.txt"); // opening the file

string str,x,y;
string substr1= "Username";
string substr2 = "Password";
int i,found;
while(file_ >> str)
{
i=0;
found = str.find(substr1); // finding username in string
if(found!= -1)
{
i = found+ 10;
while(str[i] != ';') { cout<< str[i]; i++;} // print username
  
cout<< " : ";
}

found = str.find(substr2); // finding password
if(found!= -1)
{
i = found+ 10;
while(str[i] != ';') { cout<< str[i]; i++;} // print password
cout << endl;
}

}

return 0;
}

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