Write a Menu Driven Program based on Binary file to store data ,Display ,modify, delete , search options (for Example You want to store Employee Data : Employee Code,Name,Salary,Department)
Answers
Answer:
#include<iostream>
#include<fstream>
#include<stdio.h>
using namespace std;
//Employee class Declaration
class Employee{
private:
int code;
char name[20];
float salary;
public:
void read();
void display();
//will return employee code
int getEmpCode() { return code;}
//will return employee salary
int getSalary() { return salary;}
//will update employee salary
void updateSalary(float s) { salary=s;}
};
//Read employee record
void Employee::read(){
cout<<"Enter employee code: ";
cin>>code;
cout<<"Enter name: ";
cin.ignore(1);
cin.getline(name,20);
cout<<"Enter salary: ";
cin>>salary;
}
//Display employee record
void Employee::display()
{
cout<<code<<" "<<name<<"\t"<<salary<<endl;
}
//global declaration
fstream file;
//Will delete file when program is being executed
//because we are create file in append mode
void deleteExistingFile(){
remove("EMPLOYEE.DAT");
}
//function to append record into file
void appendToFille(){
Employee x;
//Read employee record from user
x.read();
file.open("EMPLOYEE.DAT",ios::binary|ios::app);
if(!file){
cout<<"ERROR IN CREATING FILE\n";
return;
}
Answer:
.
.
.
.
In computing and telecommunications, a menu is a list of options or commands presented to the user of a computer or communications system. A menu may either be a system's entire user interface, or only part of a more complex one.