1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Y_Kistochka [10]
4 years ago
5

Write a console-based employee management system through binary File Handling (In order to observe data security, we use binary

file format so that data cannot be read directly from the TXT file) which will perform management actions of Employee by taking input from user by showing following three options:
1. Press 1 to ADD AN EMPLOYEE.
2. Press 2 to DISPLAY FILE DATA.
3. Press 3 to INCREASE EMPLOYEE SALARY.
After dealing with each option, show prompt to user and continue the program until user press other than ‘y’
Computers and Technology
1 answer:
dangina [55]4 years ago
8 0

Answer:

#include <fstream>

#include <iostream>

#define FILE_N "employee.dat"

using namespace std;

class Employee {

private :  

int  empID;

char  empName[100] ;

int  salary;

public  :

void readEmployeeDetails(){

 cout<<" PLEASE SUBMIT EMPLOYEE DETAILS"<<endl;

 cout<<"INPUT EMPLOYEE ID : " ;

 cin>>empID;

 cin.ignore(1);

 cout<<"ENTER EMPLOYEE NAME: ";

 cin.getline(empName,100);

 cout<<"ENTER EMPLOYEE SALARY : ";

 cin>>salary;

}

void increasesalary(){

 cout<<" Increment Salary"<<endl;

 cout<<"ENTER INCREMENT SALARY : ";

 int sal;

 cin>>sal;

 salary=salary + sal;

}

void displayEmployee(){

 cout<<"EMP ID: "<<empID<<endl

  <<"EMP NAME: "<<empName<<endl

  <<"SALARY: "<<salary<<endl;

}

};

int main(){

   int options;

   

LOOP:cout<<"Enter the Options:";

   cin>>options;

if(options == 1)

{

Employee emp;

emp.readEmployeeDetails();

fstream file;

file.open(FILE_N,ios::out|ios::binary);

if(!file){

 cout<<"There is an Error found while creating file...\n";

 return -1;

}

 

file.write((char*)&emp,sizeof(emp));

file.close();

cout<<"Date has been saved in the file.\n";

goto LOOP;

}

else if(options == 2)

{

Employee emp;    

fstream file;

file.open(FILE_N,ios::in|ios::binary);

if(!file){

 cout<<"There is an error while opening file...\n";

 return -1;

}

 

if(file.read((char*)&emp,sizeof(emp))){

  cout<<endl<<endl;

  cout<<"Data being discovered from the file..\n";

  emp.displayEmployee();

}

else{

 cout<<"There is an error while reading the file...\n";

 return -1;

}

goto LOOP;

}

else

{

  Employee emp;

emp.increasesalary();

fstream file;

file.open(FILE_N,ios::out|ios::binary);

if(!file){

 cout<<"Error found while creating file...\n";

 return -1;

}

 

file.write((char*)&emp,sizeof(emp));

file.close();

cout<<"Date saved inside the file.\n";

goto LOOP;

}

return 0;

}

Explanation:

The above program is in C++. It creates a class, assign it value, and then work on three option.

1. Press 1 to ADD AN EMPLOYEE.

2. Press 2 to DISPLAY FILE DATA.

3. Press 3 to INCREASE EMPLOYEE SALARY.

Rest is as shown in program.

You might be interested in
Please help me asapppp!​
pychu [463]

of which class is this question

6 0
3 years ago
Read 2 more answers
Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90)
yanalaym [24]

Answer:

The solution in python.

Output:

   print("0 is not a valid interstate highway number")

Explanation:

h = int(input("enter highway number: ")) #take highway number

if(h>=1 and h<=99): #for primary highway

   if(h%2==0):

       print("I-%d is primary, going east/west" %h) #for even highway number

   else:

       print("I-%d is primary, going north/south" %h) #for odd highway number

elif(h>=100 and h<=999): #for auxiliary highway

   aux=str(h) #convert into string for fetch the rightmost number

   l=len(aux) #find the length

   val = aux[l-2]+aux[l-1] #assign value of rightmost two number

   h = int(val) #convert into integer

   if(h%2==0):

       print("I-"+aux+" is auxiliary,"+"serving I-%d, going east/west" %h)

   else:

       print("I-"+aux+" is auxiliary,"+"serving I-%d, going north/south" %h)

elif(h==0):#for 0 highway number

   print("0 is not a valid interstate highway number")

else:

   pass

7 0
3 years ago
A user complains that Skype drops her videoconference calls and she must reconnect. At which layer of the OSI model should you b
umka2103 [35]

Answer: Application layer

Explanation:

Application layer of OSI(Open system interconnection) that is responsible for interfacing the communication with the user by displaying information or message. It maintains the transmission of file and assessment, emailing faculty, using network services etc.

  • According to the question,if any Skype user has complain regarding video call drop while conferencing then application is responsible to solve the issue.
  • This layer will be the starting point of troubleshoot by approaching to network resources.As call drop can occur due to network service, congestion or resource issue.
4 0
3 years ago
Two or more computers connected together is referred to as a(n)
oksian1 [2.3K]
That would be a network my friend. When two or more computers are connected to one another, you have a network.
8 0
3 years ago
What should you do before you share your information on the internet?
satela [25.4K]

You have to think about, what could happen to you if you shared this information.

Hope this helped!

~Izzy

4 0
3 years ago
Other questions:
  • How do you mark somebody the brainliest?
    14·2 answers
  • The code below uses the Space macro which simply displays the number of blank spaces specified by its argument. What is the firs
    9·1 answer
  • The UNIX system does not attempt to avoid cycles. Instead, it restricts access to the linking capability of the system. Normal u
    11·1 answer
  • Write a Java Program that can compute the mean, median, the highest, and the lowest of the students’ scores in a class. First, t
    6·1 answer
  • Zack is taking a survey that contains questions about his future plans. Which question would most likely be on the survey?
    9·2 answers
  • ―Connectivity is Productivity‖- Explain the statements.
    8·1 answer
  • Choose the term that best matches each definition.
    7·1 answer
  • can people be nice and just r;p with me once im getting sad because everyone is rude about it im not a creep im really nice and
    6·1 answer
  • I WILL MARK BRAINLEST
    7·1 answer
  • Can we use a data type as a condition in C++?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!