Question and compiler output with error is provided in the attachment. And my solution is provided below. kindly correct my code and make it error-free also match output. -----MY SOLUTION----- MAIN.CPP #include #include #include #include #include #include #include #include"UserBO.cpp" using namespace std; int main() { int num; cout<<"Enter the number of users:"; cin>>num; string name; string contact; string uname; string password; User U[10]; for(int i = 0; i < num; i++) { cout<>name; cout<>contact; cout<>uname; cout<>password; User k(name, uname, password, contact); U[i] = k; } ofstream file; file.open("example.txt",ios::out); UserBO ub; ub.writeUserdetails(file, U, num); return 0; } UserBo.cpp #include #include #include #include #include #include #include #include"User.cpp" using namespace std; class UserBO { public: void writeUserdetails(ofstream &file, User obj[], int m) { for(int i = 0; i < m; i++) { file< #include #include #include #include #include #include using namespace std; class User { private: string name; string username; string password; string contactnumber; public: User(){} User(string name, string username, string password, string contactnumber) { this->name = name; this->username = username; this->password = password; this->contactnumber = contactnumber; } void setName(string name) { this->name = name; } void setUsername(string uname) { this->username = uname; } void setPassword(string pass) { this->password = pass; } void setContactnumber(string connum) { this->contactnumber = connum; } string getName() { return name; } string getUsername() { return username; } string getPassword() { return password; } string getContactNumber() { return contactnumber; } };
Question and compiler output with error is provided in the attachment. And my solution is provided below. kindly correct my code and make it error-free also match output. -----MY SOLUTION----- MAIN.CPP #include #include #include #include #include #include #include #include"UserBO.cpp" using namespace std; int main() { int num; cout<<"Enter the number of users:"; cin>>num; string name; string contact; string uname; string password; User U[10]; for(int i = 0; i < num; i++) { cout<>name; cout<>contact; cout<>uname; cout<>password; User k(name, uname, password, contact); U[i] = k; } ofstream file; file.open("example.txt",ios::out); UserBO ub; ub.writeUserdetails(file, U, num); return 0; } UserBo.cpp #include #include #include #include #include #include #include #include"User.cpp" using namespace std; class UserBO { public: void writeUserdetails(ofstream &file, User obj[], int m) { for(int i = 0; i < m; i++) { file< #include #include #include #include #include #include using namespace std; class User { private: string name; string username; string password; string contactnumber; public: User(){} User(string name, string username, string password, string contactnumber) { this->name = name; this->username = username; this->password = password; this->contactnumber = contactnumber; } void setName(string name) { this->name = name; } void setUsername(string uname) { this->username = uname; } void setPassword(string pass) { this->password = pass; } void setContactnumber(string connum) { this->contactnumber = connum; } string getName() { return name; } string getUsername() { return username; } string getPassword() { return password; } string getContactNumber() { return contactnumber; } };
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Question and compiler output with error is provided in the attachment. And my solution is provided below. kindly correct my code and make it error-free also match output.
-----MY SOLUTION-----
MAIN.CPP
#include<iostream> #include<string> #include<stdio.h> #include<fstream> #include<list> #include<iterator> #include<sstream> #include"UserBO.cpp" using namespace std; int main() { int num; cout<<"Enter the number of users:"; cin>>num; string name; string contact; string uname; string password; User U[10]; for(int i = 0; i < num; i++) { cout<<endl<<"Enter the name of user :"; cin>>name; cout<<endl<<"Enter the contact number :"; cin>>contact; cout<<endl<<"Enter the username :"; cin>>uname; cout<<endl<<"Enter the password :"; cin>>password; User k(name, uname, password, contact); U[i] = k; } ofstream file; file.open("example.txt",ios::out); UserBO ub; ub.writeUserdetails(file, U, num); 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: void writeUserdetails(ofstream &file, User obj[], int m) { for(int i = 0; i < m; i++) { file<<obj[i].getName()<<","<<obj[i].getContactNumber()<<","<<obj[i].getUsername()<<","<<obj[i].getPassword()<<endl; } file.close(); } }; |
User.cpp
#include<iostream> #include<string> #include<stdio.h> #include<fstream> #include<list> #include<iterator> #include<sstream> using namespace std; class User { private: string name; string username; string password; string contactnumber; public: User(){} User(string name, string username, string password, string contactnumber) { this->name = name; this->username = username; this->password = password; this->contactnumber = contactnumber; } void setName(string name) { this->name = name; } void setUsername(string uname) { this->username = uname; } void setPassword(string pass) { this->password = pass; } void setContactnumber(string connum) { this->contactnumber = connum; } string getName() { return name; } string getUsername() { return username; } string getPassword() { return password; } string getContactNumber() { return contactnumber; } }; |
Expert Solution
Step by step
Solved in 9 steps with 5 images
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education