GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 05-Aug-2008, 15:18
bcompt143 bcompt143 is offline
Awaiting Email Confirmation
 
Join Date: Apr 2008
Posts: 22
bcompt143 is on a distinguished road
Exclamation

Please, This is Difficult question try for me!


The city administration has 3 department that are administration and planning, Management and Human resource. The human resource department needs to implement the system in to computerized form. Suppose when the human resources hire a new employee, the employee has the following information.

Personal information: full name, ID, age, sex, birthday [year/month/date]
Academic information: status [i.e. certificate, diploma, degree, master and likes], salary.
Educational background: elementary, secondary and territory school
Reference: reference name and relation.

A. Write a program that read personal and academic information from input device where personal and academic information are in separate structure and access personal information using academic structure object and display the information in output device.
B. Add a function store_onto_file (parameters) on question A and write c++ function that store the above inputs accepted from input device and store on the file “employee.dat”.
C. Add a function read_from_file (parameters) on question A and write a c++ function that read employee information from the file “employee.dat” and display on screen.
D. Add a function search_record (parameters) A, and write c++ function that you want to search record from “employee.dat” either by employee id or name.
E. Add a function display_salary (parameters) on question A and write a c++ function that sort the content of file “employee.dat” in ascending order [A-Z].
F. Add a function display_slary (parameters) on question A and write a c++ function that read salary from “employee.dat” and copy into array A [] and sort the content of array in descending order [Z-A].
G. Add a function update_record (parameters) on question A and write a c++ function that updates a specific record on the file “employee.dat”.
H. Add a function delete_record (parameters) on question A and write a c++ function that delete a specific record from the file “employee.dat”. and delete the file “employee.dat” it self from the computer.
  #2  
Old 05-Aug-2008, 15:48
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: Please, This is Difficult question try for me!


Quote:
Originally Posted by bcompt143
A. Write a program...
If you are overwhelmed by the assignment, break it down into smaller pieces. Given that it is divided into eight separate parts, A-H, ignore B-H until you have A completed. If you have further questions, post what code you have written as it can be the focus for future discussion. Good luck.
  #3  
Old 08-Aug-2008, 12:16
bcompt143 bcompt143 is offline
Awaiting Email Confirmation
 
Join Date: Apr 2008
Posts: 22
bcompt143 is on a distinguished road

Re: Please, This is Difficult question try for me!


Hello there, I have ask u becouse I have no Idea about the question! please if you have soft copy material send me or do the first question(A) to be hint for me!!!
  #4  
Old 08-Aug-2008, 12:54
ocicat ocicat is offline
Regular Member
 
Join Date: May 2008
Posts: 580
ocicat is a jewel in the roughocicat is a jewel in the rough

Re: Please, This is Difficult question try for me!


Quote:
Originally Posted by bcompt143
...or do the first question(A) to be hint for me!!!
I will give you a small hint:
CPP / C++ / C Code:
#include <iostream>
#include <fstream>

using namespace std;

int 
main() {
    ifstream fin("filename");
    string s;

    const int buffer_size = 80;
    char buffer[buffer_size];
    while (fin.getline(buffer, buffer_size)) {
        // read fields within each record
        cout << buffer;
    }

    fin.close();

    return 0;
}
Given that you have not provided any information about what compiler you are using, I can only guess whether your version can support namespaces, hence the code above.

In general, support sites like this work best when we help people find/learn how to answer the questions themselves as opposed to writing code for them. Usually assignments build on the concepts covered in class, so if you have attended, taken notes, & done the previous assignments, breaking this assignment into smaller portions should not be so overwhelming. This assignment is obviously not the first received in the course, so previous assignments should have covered the basics of control logic, file I/O & functions.
  #5  
Old 24-Aug-2008, 10:14
bcompt143 bcompt143 is offline
Awaiting Email Confirmation
 
Join Date: Apr 2008
Posts: 22
bcompt143 is on a distinguished road

Re: Urgent Please, This is Difficult question try for me!


I have tried the questions, number a, b and c and e but I gat some problem on the other question.

for your Hint How I make it, look this!

CPP / C++ / C Code:
//for question A
#include<iostream.h>
#include<conio.h>
#include<string.h>
#define max 200

struct date {
	int day;
	int month;
	int year;
	};
struct personal {
	char name[30];
	char id[30];
	int age;
	char sex[10];
	date birthday;
	};
struct acadamic {
	char status[30];
	float salary;
	personal person;
	}list[max];
void main()
{
	clrscr();
	void output(struct acadamic list[max]);

	int i;
	cout<<"enter peronal inforamio\n";
	for(i=0; i<2; i++)
	{
	cout<<"name\n";
	cin>>list[i].person.name;
	cout<<"id\n";
	cin>>list[i].person.id;
	cout<<"age\n";
	cin>>list[i].person.age;
	cout<<"sex\n";
	cin>>list[i].person.sex;
	cout<<"birthday\n";
	cin>>list[i].person.birthday.day;
	cin>>list[i].person.birthday.month;
	cin>>list[i].person.birthday.year;
	cout<<"statur\n";
	cin>>list[i].status;
	cout<<"salary\n";
	cin>>list[i].salary;
	}
	output(list);
	getch();
}

void output (struct acadamic list[max])
{
	for(int i=0; i<2; i++)
	{
	cout<<list[i].person.name<<'\t'<<list[i].person.id<<'\t'<<list[i].person.age<<'\t'<<list[i].person.sex<<list[i].person.birthday.day<<' '<<list[i].person.birthday.month<<' '<<list[i].person.birthday.year<<'\t'<<list[i].status<<'\t'<<list[i].salary<<endl;

	}
}









CPP / C++ / C Code:

//question b

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
#define max 200

struct date {
	int day;
	int month;
	int year;
	};
struct personal {
	char name[30];
	char id[30];
	int age;
	char sex[10];
	date birthday;
	};
struct acadamic {
	char status[30];
	float salary;
	personal person;
	}list[max];

void main()
{
	clrscr();
	void store_onto_file(struct acadamic list[max]);
	int i;
	cout<<"enter peronal inforamio\n";
	for(i=0; i<2; i++)
	{
	cout<<"name\n";
	cin>>list[i].person.name;
	cout<<"id\n";
	cin>>list[i].person.id;
	cout<<"age\n";
	cin>>list[i].person.age;
	cout<<"sex\n";
	cin>>list[i].person.sex;
	cout<<"birthday\n";
	cin>>list[i].person.birthday.day;
	cin>>list[i].person.birthday.month;
	cin>>list[i].person.birthday.year;
	cout<<"statur\n";
	cin>>list[i].status;
	cout<<"salary\n";
	cin>>list[i].salary;
	}
	store_onto_file(list);
	getch();
}

void store_onto_file (acadamic list[max])
{
	int i=0;
	ofstream bfile;
	bfile.open ("employee.txt", ios::out);
	while(i<2)
	{
	bfile<<list[i].person.name;
	bfile<<list[i].person.id;
	bfile<<list[i].person.age;
	bfile<<list[i].person.sex;
	bfile<<list[i].person.birthday.day;
	bfile<<list[i].person.birthday.month;
	bfile<<list[i].person.birthday.year;
	bfile<<list[i].status;
	bfile<<list[i].salary;
	i++;
	}

}




CPP / C++ / C Code:
//question c

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<fstream.h>
#define max 200

struct date {
	int day;
	int month;
	int year;
	};
struct personal {
	char name[30];
	char id[30];
	int age;
	char sex[10];
	date birthday;
	};
struct acadamic {
	char status[30];
	float salary;
	personal person;
	}list[max];
void main()
{
	clrscr();
	void read_from_file(struct acadamic list[max]);
   read_from_file(list);
	int i;
	cout<<"enter peronal inforamio\n";
	for(i=0; i<2; i++)
	{
	cout<<"name\n";
	cin>>list[i].person.name;
	cout<<"id\n";
	cin>>list[i].person.id;
	cout<<"age\n";
	cin>>list[i].person.age;
	cout<<"sex\n";
	cin>>list[i].person.sex;
	cout<<"birthday\n";
	cin>>list[i].person.birthday.day;
	cin>>list[i].person.birthday.month;
	cin>>list[i].person.birthday.year;
	cout<<"statur\n";
	cin>>list[i].status;
	cout<<"salary\n";
	cin>>list[i].salary;
	}
	read_from_file(list);
	getch();
}

void read_from_file(acadamic list[max])
{
	int  i=0;
	ifstream bfile;
	bfile.open ("employee.txt", ios::in);
	while(i<2)
	{
	bfile>>list[i].person.name;
	bfile>>list[i].person.id;
	bfile>>list[i].person.age;
	bfile>>list[i].person.sex;
	bfile>>list[i].person.birthday.day;
	bfile>>list[i].person.birthday.month;
	bfile>>list[i].person.birthday.year;
	bfile>>list[i].status;
	bfile>>list[i].salary;

	cout<<list[i].person.name<<'\t'<<list[i].person.id<<'\t'<<list[i].person.age<<'\t'<<list[i].person.sex<<list[i].person.birthday.day<<' '<<list[i].person.birthday.month<<' '<<list[i].person.birthday.year<<'\t'<<list[i].status<<'\t'<<list[i].salary<<endl;
	i++;
	}

}



CPP / C++ / C Code:
//question e

#include<iostream.h>
#include<conio.h>
#include<string.h>
#define max 200

struct date {
	int day;
	int month;
	int year;
	};
struct personal {
	char name[30];
	char id[30];
	int age;
	char sex[10];
	date birthday;
	};
struct acadamic {
	char status[30];
	float salary;
	personal person;
	}list[max];
void main()
{
	clrscr();
	void sort(struct acadamic list[max]);
	void output(struct acadamic list[max]);
	int i;
	cout<<"enter peronal inforamio\n";
	for(i=0; i<2; i++)
	{
	cout<<"name\n";
	cin>>list[i].person.name;
	cout<<"id\n";
	cin>>list[i].person.id;
	cout<<"age\n";
	cin>>list[i].person.age;
	cout<<"sex\n";
	cin>>list[i].person.sex;
	cout<<"birthday\n";
	cin>>list[i].person.birthday.day;
	cin>>list[i].person.birthday.month;
	cin>>list[i].person.birthday.year;
	cout<<"statur\n";
	cin>>list[i].status;
	cout<<"salary\n";
	cin>>list[i].salary;
	}
	output(list);
	sort(list);
	output(list);
	getch();
}

void sort (acadamic list[max])
{
	struct acadamic temp;
	for(int i=0; i<2; i++)
	{
		for(int j=0; j<2; j++)
		{
		  if(strcmp(list[i].person.name, list[j].person.name)<=0)
		  {
		  temp=list[i];
		  list[i]=list[j];
		  list[j]=temp;
		  }
		}
	}
}

void output (struct acadamic list[max])
{
	for(int i=0; i<2; i++)
	{
	cout<<list[i].person.name<<'\t'<<list[i].person.id<<'\t'<<list[i].person.age<<'\t'<<list[i].person.sex<<list[i].person.birthday.day<<' '<<list[i].person.birthday.month<<' '<<list[i].person.birthday.year<<'\t'<<list[i].status<<'\t'<<list[i].salary<<endl;

	}
}





the program succefully run. but if you have any suggestion on them please tell. I have get problem on the question D, f, g and h I cant able to serch for records on the file "employee.txt" please show me how to creat serch function for this fiel.

the other is I can sort the record but the problem is I cant sort the records which is found on the "employee.txt"

I cant able to copy the content to array A[] so please give me some hint for coping from file "employeethe.txt"

How can update the record and how can remove the content of the record or remove the record itself. the record is found on employee.txt

NOTE that my compilr is Turbo C++
.
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about locking surfaces to directly access pixels, SDL. george89 C++ Forum 0 18-Jun-2006 22:16
question on sorting items is not clear...plz help me gvsivannarayana C Programming Language 0 28-Mar-2006 01:26
question of practice magiccreative C++ Forum 1 06-Feb-2004 08:17
a C input question tmike C Programming Language 1 16-Sep-2003 03:31

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:36.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.