Please write code in C++ that will work with Dev C++ program. Thank you so much
ID: 3833573 • Letter: P
Question
Please write code in C++ that will work with Dev C++ program. Thank you so much in advance! I'm not sure what a database. I have never made a program like this before. It is for a CIST 2361 C++ project, and I provided all the information I have for it so I guess whatever you think would be best for that. Thank you. Could you provide the necessary comments as well.
Serendipity Engineering, Inc.
Software Development Project
Program Specifications:
Serendipity Engineering, Inc. is a small engineering company located in a commercial park. The project manager wants you to develop a customer software package that will allow the company enter the customer information in the computer to keep a customer database. The software will perform the following tasks:
Enter Customer Information
Display Customer Information
Search Customer Information
Organize (Sort) Customer Information
Add, Delete, Modify, and Look Up Customer Records
Save Customer Information in a Database File
Display various reports
The Modules
The program will be organized into the following modules:
• Customer Information Input Module (CIIM)
• Customer Information Display Module (CIDM)
• Customer Information Search Module (CISM)
• Customer Information Organize Module (CIOM)
• Customer Information Modify Module (CIMM)
• Customer Information DB Module (CIDBM)
• Customer Information Report Module (CIRM)
The Program
When the program runs, a menu will be displayed on the screen, which allows the user to activate any of the tasks allowed in the program. A discussion of each module follows.
Customer Information Input Module (CIIM)
The module Customer Information Input Module allows the computer to act as a customer information repository. The user enters information of the customer. You must include the Customer Number, SS Number, First Name, Last Name, Address and Telephone Number. The information will be inserted into an array automatically.
The following information for each project will be stored in the array:
Field
Description
CSNO
Customer ID. Unique number assigned to the customer by the DB manager.
SSNO
Social security number
FName
Customer first name.
LName
Customer last name.
ADDRS
Customer address.
PHONE
Customer telephone number.
The Project Designs Database module will allow the user to look up information on any project in the file, add new projects to the file, delete projects, and change any information in the database.
Customer Information Display Module (CIDM)
The Customer Information Display Module will display the customer information in the computer monitor. You will decide what information to display.
Customer Information Search Module (CISM)
The Customer Information Search Module will provide a menu input to choose what information to search for. The menu should include:
Search by Customer Number
Search by SS Number
Search by Last Name
The module must be able to perform all three searches.
Customer Information Organize Module (CIOM)
The Customer Information Organize Module will be able to organize the information by ascending order of the Customer Number, SS Number or Last Name. The module will include a menu to choose what organization mode will be used. The module must be able to perform all three modes of organization.
Customer Information Modify Module (CIMM)
The Customer Information Modify Module will allow to add, delete, modify and display a customer record. The module will include a menu to decide what modification task will be performed on the customer information.
Customer Information DB Module (CIDBM)
The Customer Information DB Module will create, save and modify a Database File.
Customer Information Report Module (CIRM)
The Customer Information Report Module will be able to generate and print the following reports:
Customer Name and Mailing Address Report
Customer Name and Phone Number Report
Final Report:
The final report, created with a word processor, will include:
Front Page with the title of your project and the name you given to the software package you have developed.
Description, in your own words, of the software specifications and capabilities.
Develop a model of the program by creating a hierarchy chart, a flowchart of one of the modules and the pseudocode of one of the functions.
Screen shot of each of the displays in your program.
Copy of the program with proper comments!
Dev C++ program compiled without errors in a zip file.
Copy of your database file, with at least 10 records.
Item
Y/N
Documentation
Front Page Title & Software Name
Description Software Specifications and Capabilities
Hierarchy Chart
Flowchart
Pseudocode
Screen Shots
Program Copy with comments
Program compiled without errors in a zip file
Database File with 10 records
Working Modules
Input Module
Display Module
Search Module
Organize Module
Modify Module
DB Module - File
Report Module
Field
Description
CSNO
Customer ID. Unique number assigned to the customer by the DB manager.
SSNO
Social security number
FName
Customer first name.
LName
Customer last name.
ADDRS
Customer address.
PHONE
Customer telephone number.
Explanation / Answer
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
using namespace std;
class file
{
private:
int cId;
char ssNumber[100];
char fName[100];
char lName[100];
char address[100];
char phone[100];
public:
void input();
void show();
char *getfn()
{
return fName;
}
char *getn()
{
return lName;
}
int getcId()
{
return cId;
}
char *getssn()
{
return ssNumber;
}
};
file fileobj;
void file::input()
{
cout<<"Enter your Customer Id : ";
cin >> cId;
cout << "Enter your S.S.Number : ";
cin >> ssNumber;
cout << "Enter your First Name : ";
cin >> fName;
cout << "Enter your Last Name : ";
cin >> lName;
cout << "Enter your Address : ";
cin >> address;
cout << "Enter your Phone Number : ";
cin >> phone;
}
void file::show()
{
cout<<"Customer Id ==> "<< cId<<endl;
cout<<"S.S. Number ==> "<< ssNumber<<endl;
cout<<"First Name==> "<< fName<<endl;
cout << "Last Name ==>" << lName<< endl;
cout << "Address ==>" << address<< endl;
cout << "Phone Number ==>"<< phone<< endl;
}
void Create();
void Add();
void DisplayAll();
void DisplayP();
void Modify();
void Delete();
void DisplayByCustomerId();
void DisplayBySSN();
void DisplayByLName();
fstream fil;
int main()
{
int opt;
while(1)
{
cout<<"1.Create Data File "<<endl;
cout<<"2.Add New Record in Data File "<<endl;
cout<<"3.Display Record From Data File "<<endl;
cout<<"4.Search Particular Record From Data File By Customer ID "<<endl;
cout<<"5.Search Particular Record From Data File By Social Security Number "<<endl;
cout<<"6.Search Particular Record From Data File By LastName "<<endl;
cout<<"7.Modify Particular Record From Data File "<<endl;
cout<<"8.Delete Particular Record From Data File "<<endl;
cout<<"9.Exit From the Program"<<endl;
cout << endl;
cout<<"Enter your Option : "<<endl;
cin>>opt;
switch(opt)
{
case 1:
{
Create();
cout<<"Display Main Menu"<<endl;
break;
}
case 2:
{
Add();
cout<<"Display Main Menu"<<endl;
break;
}
case 3:
{
DisplayAll();
cout<<"Display Main Menu"<<endl;
break;
}
case 4:
{
DisplayByCustomerId();
cout<<"Display Main Menu"<<endl;
break;
}
case 5:
{
DisplayBySSN();
cout<<"Display Main Menu"<<endl;
break;
}
case 6:
{
DisplayByLName();
cout<<"Display Main Menu"<<endl;
break;
}
case 7:
{
Modify();
cout<<"Display Main Menu"<<endl;
break;
}
case 8:
{
Delete();
cout<<"Display Main Menu"<<endl;
break;
}
case 9:
{
exit(0);
}
default:
{
cout<<"Wrong Choice....Press Key For View the Main Menu" << endl;
}
}
}
}
void Create() //Function to Create Data File
{
char ch='y';
fil.open("customer.txt",ios::out| ios::binary);
while(ch=='y' || ch =='Y')
{
fileobj.input();
fil.write((char*)&fileobj, sizeof(fileobj));
cout<<endl << "Want to Continue (Y/N)....." << endl;
cin>>ch;
}
fil.close();
}
void Add() //Function to Add New Record in Data File
{
char ch='y';
fil.open("customer.txt",ios::app| ios::binary);
while(ch=='y' || ch =='Y')
{
fileobj.input();
fil.write((char*)&fileobj, sizeof(fileobj));
cout<<endl << "Want to Continue (Y/N) ..... "<< endl;
cin>>ch;
}
fil.close();
}
void DisplayAll() //Function to Display All Record from Data File
{
fil.open("customer.txt",ios::in| ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
fileobj.show();
cout<<"Press Any Key For Next Record"<<endl;
getch();
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
fil.close();
}
void DisplayByLName() //Function to Display particular Record from Data File on the basis of Last name
{
char n[100];
cout<<"Enter Last Name that should be searched : ";
cin >> n;
fil.open("customer.txt",ios::in| ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
if(strcmp(n,fileobj.getn())==0)
{
fileobj.show();
cout<<"Press Any Key...."<<endl;
getch();
}
else
{
cout<<"Press Any Key For Search"<<endl;
getch();
}
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
fil.close();
}
void DisplayByCustomerId() //Function to Display particular Record from Data File on the basis of customer id
{
int n;
cout<<"Enter Customer Id that should be searched : ";
cin >> n;
fil.open("customer.txt",ios::in| ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
if(n == fileobj.getcId())
{
fileobj.show();
cout<<"Press Any Key to Quit"<<endl;
getch();
}
else
{
cout<<"Press Any Key For Search"<<endl;
getch();
}
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
fil.close();
}
void DisplayBySSN() //Function to Display particular Record from Data File on the basis of SSN
{
char n[100];
cout<<"Enter S.S.Number that should be searched : ";
cin >> n;
fil.open("customer.txt",ios::in| ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
if(strcmp(n,fileobj.getssn())==0)
{
fileobj.show();
cout<<"Press Any Key...."<<endl;
getch();
}
else
{
cout<<"Press Any Key For Search"<<endl;
getch();
}
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
fil.close();
}
void Modify() //Function to Modify Particular Record from Data File
{
char n[100];
cout<<"Enter First Name that should be searched : ";
cin >> n;
fil.open("customer.txt",ios::in| ios::out|ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
if(strcmp(n,fileobj.getfn())==0)
{
fil.seekg(0,ios::cur);
cout<<"Enter New Record.."<<endl;
fileobj.input();
fil.seekp(fil.tellg() - sizeof(fileobj));
fil.write((char*)&fileobj, sizeof(fileobj));
}
else
{
cout<<"Press Any Key For Search"<<endl;
getch();
}
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
fil.close();
}
void Delete() //Function to Delete Particular Record from Data File
{
char n[100];
cout<<"Enter First Name that should be Deleted : ";
cin >> n;
ofstream o;
o.open("new_customer.txt",ios::out|ios::binary);
fil.open("customer.txt",ios::in| ios::binary);
if(!fil)
{
cout<<"File not Found";
exit(0);
}
else
{
fil.read((char*)&fileobj, sizeof(fileobj));
while(!fil.eof())
{
if(strcmp(n,fileobj.getfn())!=0)
{
o.write((char*)&fileobj, sizeof(fileobj));
}
else
{
cout<<"Press Any Key For Search"<<endl;
getch();
}
fil.read((char*)&fileobj, sizeof(fileobj));
}
}
o.close();
fil.close();
remove("customer.txt");
rename("new_customer.txt", "customer.txt");
}//end of program