ABC Bank needs to store the information of all the users. For a user, the information that the bank holds is the user's name, username, password, contact number. Read this data from the console and store it in a file named "example.txt". Write a C++ program to read inputs from the console and write the user details into a file as the comma-separated values. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. File names used should be the same as mentioned in the problem description. The class named User has the following private member variables Data type string string string string Variable name name username password contactnumber Define the following member function in the class UserBO. Method name Description This function accepts a user object and an ofstream file object. The function is used to write the data into the file. void writeUserdetails(ofstream &file,User obj) In the main method, read the input from the user through the console and open a file named "example.txt", into which the data are needed to be written. Pass the file object to the writeUserdetails() function and write the inputs as comma-separated-values into the file. Input and Output format: Refer sample input and output for formatting specifications. Sample input and output 1: [All text in bold corresponds to input and rest corresponds to output] Enter the name of user: ramesh Enter the contact number: 900900901 Enter the username: ramesh123 Enter the password: qwertyramesh Datas written in file successfully sample output in file: (example.txt) ramesh,900900901,ramesh123,qwertyramesh

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

QUESTION IN ATTACHMENT! PLEASE CHECK

----AND ITS HUMBLE REQUEST TO USE ONLY BELOW TEMPLATES WHILE MAKING SOLUTION-----

 

MAIN.CPP

#include<iostream>
#include<string>
#include<stdio.h>
#include<fstream>
#include<list>
#include<iterator>
#include<sstream>
#include <iostream>
#include "UserBO.cpp"

using namespace std;

int main()
{
// fill your code here
// declare variables
string name;
string username;
string password;
string contactnumber;
// create a User class object
User obj;
// create a object of ofstream class
ofstream outfile;
outfile.open("example.txt");// open file example.txt
UserBO userObj;// create a object of class UserBO userObj for write in file
int choice;
int i=1;

// input from user
do{
cout<<"Sample input and output : "<<i++<<endl;
cout<<"Enter the name of user "<<endl;
cin>>name;
cout<<"Enter the contact number "<<endl;
cin>>contactnumber;
cout<<"Enter the username"<<endl;
cin>>username;
cout<<"Enter the password "<<endl;
cin>>password;

obj.setName(name);
obj.setContactnumber(contactnumber);
obj.setUsername(username);
obj.setPassword(password);

userObj.writeUserdetails( outfile ,obj); // wirte in file
cout<<"Press 1-> countinue \nPress 0-> exit \nChoice : ";
cin>>choice;
}while(choice!=0);

// close the opened file.
outfile.close();
return 0;
}

 

UserBO.cpp

 

#include<iostream>
#include<string>
#include<stdio.h>
#include<fstream>
#include<list>
#include<iterator>
#include<sstream>
#include"User.cpp"
using namespace std;

class UserBO{
public:
// writeUserdetails() function write data into file
void writeUserdetails(ofstream &file,User Obj){
// fill your code here;
// write data into the file.
file << Obj.getName() << ","<< Obj.getContactnumber() << ","<< Obj.getUsername() << ","<< Obj.getPassword() << endl;
cout<<"Datas writtrn in successfully"<<endl;
}

};

 

User.cpp

#include<iostream>
#include<string>
#include<stdio.h>
#include<fstream>
#include<list>
#include<iterator>
#include<sstream>
using namespace std;

class User{
// private variable declare
private:
string name;
string username;
string password;
string contactnumber;

public:
// set name
void setName(string name){
this->name = name;
}
// get name
string getName(){
return this->name ;
}
// set username
void setUsername(string username){
this->username = username;
}
/// get username
string getUsername(){
return this->username;
}
// set password
void setPassword(string password){
this->password = password;
}
// get password
string getPassword(){
return this->password;
}
// set contactnumber
void setContactnumber(string contactnumber){
this->contactnumber = contactnumber;
}
// get contactnumber
string getContactnumber(){
return this->contactnumber;
}
};

ABC Bank needs to store the information of all the users. For a user, the information that the bank
holds is the user's name, username, password, contact number. Read this data from the console and
store it in a file named "example.txt".
Write a C++ program to read inputs from the console and write the user details into a file as the
comma-separated values.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class
names, member variable names, and function names should be the same as specified in the problem
statement. File names used should be the same as mentioned in the problem description.
The class named User has the following private member variables
Data type
string
string
string
string
Variable name
name
username
password
contactnumber
Define the following member function in the class UserBO.
Method name
Description
This function accepts a user object and an ofstream file
object. The function is used to write the data into the file.
void writeUserdetails(ofstream &file,User obj)
In the main method, read the input from the user through the console and open a file named
"example.txt", into which the data are needed to be written. Pass the file object to the
writeUserdetails() function and write the inputs as comma-separated-values into the file.
Input and Output format:
Refer sample input and output for formatting specifications.
Sample input and output 1:
[All text in bold corresponds to input and rest corresponds to output]
Enter the name of user:
ramesh
Enter the contact number:
900900901
Enter the username:
ramesh123
Enter the password:
qwertyramesh
Datas written in file successfully
sample output in file: (example.txt)
ramesh,900900901,ramesh123,qwertyramesh
Transcribed Image Text:ABC Bank needs to store the information of all the users. For a user, the information that the bank holds is the user's name, username, password, contact number. Read this data from the console and store it in a file named "example.txt". Write a C++ program to read inputs from the console and write the user details into a file as the comma-separated values. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. File names used should be the same as mentioned in the problem description. The class named User has the following private member variables Data type string string string string Variable name name username password contactnumber Define the following member function in the class UserBO. Method name Description This function accepts a user object and an ofstream file object. The function is used to write the data into the file. void writeUserdetails(ofstream &file,User obj) In the main method, read the input from the user through the console and open a file named "example.txt", into which the data are needed to be written. Pass the file object to the writeUserdetails() function and write the inputs as comma-separated-values into the file. Input and Output format: Refer sample input and output for formatting specifications. Sample input and output 1: [All text in bold corresponds to input and rest corresponds to output] Enter the name of user: ramesh Enter the contact number: 900900901 Enter the username: ramesh123 Enter the password: qwertyramesh Datas written in file successfully sample output in file: (example.txt) ramesh,900900901,ramesh123,qwertyramesh
Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY