|
|
|
|
|
| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19 Feb 2008 13:48:11 IST
|
|
|
#include<iostream.h> #include<conio.h> #include<string.h> #include<stdio.h> #include<stdlib.h> int x=0; class worker { char name[10]; int hrs; int wage_rate; int total_wage; public: void get_data(); void put_data(); void insert(int); void delete_record(int); }A[10]; void worker :: get_data() { cout<<"\n\nEntering data"; cout<<"\n-------------"; cout<<"\n\nEnter workers name:: "; gets(name); cout<<"\nEnter hours worked:: "; cin>>hrs; cout<<"\nEnter the wage rate:: "; cin>>wage_rate; total_wage = (hrs * wage_rate); cout<<"\nTotal wage is:: "<<total_wage; } void worker :: put_data() { cout<<"\n\n\nDisplaying data"; cout<<"\n--------------"; cout<<"\n\nWorkers name:: "; puts(name); cout<<"\nHours worked:: "<<hrs; cout<<"\n\nWage rate:: "<<wage_rate; cout<<"\n\nTotal wage:: "<<total_wage; } void worker :: insert(int a) { for(int i=x;i>=a;i--) { A[i]=A[i-1]; } A[a].get_data(); x=x+1; }
void worker :: delete_record(int b) { for(int i=b;i<x;i++) { A[i]=A[i+1]; } cout<<"\n\nRecord deleted"; x=x-1; }
void main() { clrscr(); char ch; cout<<" WORKER\n"; cout<<" ------"; cout<<"\n\nEnter the number of persons:: "; cin>>x; do { int n; cout<<"\n\nMenu"; cout<<"\n----"; cout<<"\n\n1.Enter data"; cout<<"\n\n2.Display data"; cout<<"\n\n3.Insert record"; cout<<"\n\n4.Delete record"; cout<<"\n\n5.Exit"; cout<<"\n\n\nEnter your choice:: "; cin>>n; if(n==1) { clrscr(); for(int i=0;i<x;i++) A[i].get_data(); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==2) { clrscr(); for(int i=0;i<x;i++) A[i].put_data(); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==3) { clrscr(); cout<<"\n\nInserting Record"; cout<<"\n-----------------"; int m; cout<<"\n\nEnter the position:: "; cin>>m; A[m-1].insert(m-1); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==4) { clrscr(); cout<<"\n\nDeleting Record"; cout<<"\n----------------"; int p; cout<<"Enter the position:: "; cin>>p; A[p-1].delete_record(p-1); cout<<"\n\nDo you want to continue:: "; cin>>ch; } if(n==5) { exit(0); } }while(ch=='y'); }
|
Be not afraid of growing slowly.
Be afraid only of standing still.
|
this reply: 10 points
(with 2 
in 2 votes ) [?]
|
|
You have to be logged on to rate
|
|
|
|
|
|
|
|
|
|