plz i wanna sol for this q with describ
anyone can help me ???

write C++ program cosist of two structures
- The first called "Address" consist of three elements (city, state, and zip code).
- The second called "Employee" consist of seven elements ( Employee name,
number, Address, Birthdate, telephone, grade{A, B, C, or D}, salary).
Employee Salary depend on degree of Employee
- Grade "A" salary is 800$
- Grade "B" salary is 700$
- Grade "C" salary is 600$
- Other Grade salary is 500$
The program display the Next menu on the screen to ask user to choice operation
1- Enter New Employee record to the file.
2- Search for a particular Employee's record and display it.
3- Search for a particular Employee's record and change it.
4- Display the contents of the entire file.
5- Exit
Enter your choice
Choice 1 :
Call function is called "AddRecord", in the function open a file and then store
information of one employee and then close the file.
Choice 2:
Call function is called "DisplayRecord", in the function open a file, and ask user
to enter Employee number, and then search in the file, if number in the file show
all other information of this employee.
Choice 3:
Call function is called "ChangeRecord", in the function open a file, and ask user
to enter Employee number, and then search in the file, if number in the file, ask
user to enter new information to this employee.
Choice 4:
Call function is called "Display", in th function open file, and display all
contents of the file.

Recommended Answers

All 11 Replies

What have you done so far to solve this problem?

I not understande this Q , iam new in programming ??

Well, your assignment is already well-described. It's already told you what structure and functions you need.

In other words, you haven't done anything. Well, when programmers are given a big, complicated problem, they break it down into manageable parts and deal with them individually. If you're new to programming, start with this part:

write C++ program

That gives you an empty program to start from, and you can incrementally add bits and pieces that you understand. Until you have code that shows you've tried something, or ask a specific question about the problem, you won't get very good help.

i know c++ but i wanna code this q

Then start to write some codes. First of all, Read the assigment and follow what it wants you to do.

write C++ program cosist of two structures
- The first called "Address" consist of three elements (city, state, and zip code).

Do you know how to declare the structure?


1- Enter New Employee record to the file.
2- Search for a particular Employee's record and display it.
3- Search for a particular Employee's record and change it.
4- Display the contents of the entire file.
5- Exit

Do you know how to get input? The use switch().

Choice 1 :
Call function is called "AddRecord", in the function open a file and then store
information of one employee and then close the file.

Do you know how to make function? Have you learned how to read and write a file?

Thanx , i know using "case" statement but i not understand read and write a file so i want describe for this q cuz iam can't understand it from my teacher

see that and tell me about this :

#include <iostream.h>
#include<fstream.h>
#include<iomainp.h>
#include<stdlib.h>


struct address
{
char city[20];
char state[20];
int zip;
};
struct  Employee
{
char name[20];
int number;
address place;
int birthday;
int tel;
char grade;
float salary;
};


menu();
int main()
{


..
cout<<..........
cout<<.......
cout<<.........;
cout<<...........;
do
{
select = menu();
switch(select)
{
case 1 :
...
...
..
.
.i want read and write file ????
.
.
.
.
}
if (select < 5)
{
displayinfo;
saveinfo;
}
}while (select !=6);
cout << " close";
}
menu();
int main()
{

..
cout<<..........
cout<<.......
cout<<.........;
cout<<...........;
do
{
select = menu();
switch(select)
{
case 1 :

Why you need menu() function? When you can input by using std::cin >> select;. And your switch should looks like this:

switch(select)
case 1:
   AddRecord();
   break;
case 2:
   DisplayRecord();
   break;
...
...
....

Why I was doing like this? Because your assigment want you to create these function:
AddRecord() run this function when the user choose number 1
DisplayRecord() run this function when the user choose number 2
ChangeRecord() run this function when the user choose number 3
Display() run this function when the user choose number 4

Thanx im understand now but how is a code for that statements ?

Choice 2:
Call function is called "DisplayRecord", in the function open a file, and ask user
to enter Employee number, and then search in the file, if number in the file show
all other information of this employee.
Choice 3:
Call function is called "ChangeRecord", in the function open a file, and ask user
to enter Employee number, and then search in the file, if number in the file, ask
user to enter new information to this employee.

Choice 1 :
Call function is called "AddRecord", in the function open a file and then store
information of one employee and then close the file.

Invent the function AddRecord() which ask the user to input all the information about one employee and store it in a file. The information should be include every elements in Employee stucture.

void AddRecord()
{
   // Ask for employee name
   // Ask for number
   // Ask for Address
   // Ask for birthday
   // Ask for telephone
   // Ask for salary

   // Open the file
   // Write all the informations into the file
   // Close the file
}

Choice 2:
Call function is called "DisplayRecord", in the function open a file, and ask user
to enter Employee number, and then search in the file, if number in the file show
all other information of this employee.

Invent another function which is called DisplayRecord(). This function will ask user to enter employee number, and then search in the file and if it found, then show all the information of that employee.

void DisplayRecord()
{
   // Ask for employee number

   // Search for the file

   // Output employee name
   // Output number
   // Output Address
   // Output birthday
   // Output telephone
   // Output salary
}

.....

Thanx A lot

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.