•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 426,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,555 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1175 | Replies: 8
•
•
Join Date: May 2005
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
This program supposed to ask the user to enter the names and the ID numbers and
the number of children the employee have,
the search shoud work like this
taylar 845 3
john 123 2
sara 526 2
**search by name**
the user should enter the employee name he's searching for
if he entered sara
sara 526 2
**search by number of children**
if the user enterd 2
john 123 2
sara 526 2
**sort by name**
the names sould sorted in alphapatical order
john 123 2
sara 526 2
taylar 845 3
************************************
This program supposed to ask the user to enter the names and the ID numbers and
the number of children the employee have,
the search shoud work like this
taylar 845 3
john 123 2
sara 526 2
**search by name**
the user should enter the employee name he's searching for
if he entered sara
sara 526 2
**search by number of children**
if the user enterd 2
john 123 2
sara 526 2
**sort by name**
the names sould sorted in alphapatical order
john 123 2
sara 526 2
taylar 845 3
************************************
#include <iostream>
#include <cstring>
using namespace::std;
int main ()
{
int counter=0;
char *s[100];
char names[100];
int num[3];
char *j;
int child[3];
int x,n,y,s1,s2;
cout <<"Input the information of 10 imployees: "<< endl;
cout << "Names "<< "Number" <<" childs"<<endl;
for ( int i=0 ; i <3 ; i++ ){
s[i]= names;
cin >> names ;
cout<< "\t";
cin >> num[i] ;
cout << "\t";
cin >> child[i] ;
cout<< "\t" ;
cout << endl;
}
cout << "What type of operation you are interested in: " << endl;
cout << " 1. Search by Employee name" << endl;
cout << " 2. Search by Number of childrean" << endl;
cout << " 3. Sort by Name" << endl;
cout << " 4. To Exit" << endl;
cin >> x ;
while ( x != 4 ) {
if ( x == 1 ) {
cout << "Input the employee name:" << endl;
cin >> j ;
for ( i=0 ; i < 3 ; i++ )
{
int n;
n = strcmp( j , s[i]);
if ( n=0)
{
cout << "The employee you are looking for are :" << endl;
cout << s[i] <<"\t"<< num[i] <<"\t"<< child[i] << endl;
}
}
}
if ( x == 2 ){
cout << "What is the number of children you are looking for:" << endl;
cin >> n;
cout << "The employees you are looking for are:" << endl;
for ( i=0 ; i < 3 ; i++ ){
if ( child[i] == n )
cout << s[i] <<"\t"<< num[i] << "\t" << child[i] << endl;
}
}
if ( x == 3 ){
for ( i=0 ; i <3 ; i++ ){
s1=*s[i];
s2=*s[i+1];
y=strcmp ( s[i] , s[i+1]);
if ( y == 1 ) {
*s[i] = s1;
*s[i+1]=s2;
}
else {
*s[i]=s2;
*s[i+1]=s1;
}
}
cout << "Sort by Name:" << endl;
for ( i=0 ; i<3 ; i++ )
cout << s[i] << "\t" << num[i] << "\t" << child[i] << endl;
}
}
return 0;
}•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the C++ Forum
- Previous Thread: Lumping C and C++ together..
- Next Thread: postfix evaluation



Threaded Mode