[C++ visual studio 2015] Create a text file with redacted information. Use OOP d
ID: 3576050 • Letter: #
Question
[C++ visual studio 2015]
Create a text file with redacted information.
Use OOP design paradigm, Classes, Inheritance, and Access modifiers.
ofstream input information on 10 students into a text file.
student ID, First Name, Last Name, DOB, and address.
Create a header row for your student information.
Take birthdate information and redact month and day before values are output to text file. Create a Derived/sub class that handles the redaction.
Attach Snipping photo source code and file containing student information. (See attached text file photo below.)
Redacted txt Notepad File Edit Format View Help Student ID# First Name 123 Tim Diablo 150 999 Tom Buffy 100 225 LeRoy 849 Bruce 124 Tom 126 Dick 150 Harry 643 Jane Last Name Smith HO Doe Slayer Lee Smith Smith Holiday Doe DOB 1996XXXXXX 1990 XXXX 1986XXXX 1996 XXXX 2001-XXXX 1956XXXX 1989 XXXX 1988XXXX 1987 XXXX 1986XXXXXX Address 777 Heavens Way 666 Hells Gate 999 Nevermind 456 Seven 123 Right Here Alley 333 Enter The Dragon 321 Zero 836 Pick up sticks 577 Eleven 888 HiaghtExplanation / Answer
#include <fstream>
#include<iostream>
#include<cstdlib>
using namespace std;
class student{
public:
string id,fname,lname,dob,addr;
student(){
id="";
fname="";
lname="";
dob="";
addr="";
}
void getData(){
cout<<" Enter your first name:";
getline(cin,fname);
cout<<" Enter your last name:";
getline(cin,lname);
cout<<" Enter your ID:";
getline(cin,id);
cout<<" Enter your date of birth(dd/mm/yy):";
getline(cin,dob);
cout<<" Enter your address:";
getline(cin,addr);
}
};
class redactor:public student{
public:
void writeData(){
cout<<" ID:"<<id;
cout<<" First name:"<<fname;
cout<<" Last Name:"<<lname;
cout<<" DOB:"<<dob;
cout<<" Address:"<<addr;
}
};
int main(){
redactor r[10];
ofstream fileName;
//opening file for appending mode
fileName.open("Redacted.txt", ios::out|ios::app);
fileName<<"Student ID#"<<" First Name"<<" Last Name"<<" DOB"<<" Address"<<endl;
for(int i=0;i<10;i++){
r[i].getData();
fileName<<r[i].id<<" "<<r[i].fname<<" "<<r[i].lname<<" "<<r[i].dob<<" "<<r[i].addr<<endl;
}
for(int i=0;i<10;i++){
r[i].writeData();
}
fileName.close();
cin.clear();
fflush(stdin);
return 0;
return 0;
}
*********************output file Redacted.txt********************************
Student ID# First Name Last Name DOB Address
123 Tim Smith 1996xxxx 777 Heavens way
150 Diablo Ho 1990xxxx 666 Hells Gate
999 Tom Doe 1986xxxx 999 Nevermind
100 Buffy Slayer 1996xxxx 456 Seven
225 LeRoy jackson 2001xxxx 123 Right Here Alley
.
.
.
.
.
.
.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.