Programming help for \'C\' Language. With this assignment you will start to lear
ID: 3765836 • Letter: P
Question
Programming help for 'C' Language.
With this assignment you will start to learn how to write a practical menu driven program that manages a list of data. You will use an array of structs to organize the data and you will save the information in a text file.
The assignment is to write a menu driven program that manages a small business inventory, collection or list. You pick the topic!!! The focus of your program is up to you.
The Menu commands must include:
P....Display all records (on the screen/monitor)
S....Create a current report (save it to a file)
A....Add a new entry
D....Delete an item from the list (inventory)
C....Clear all records
Q...Quit
You must add (1) additional menu option that you choose.It may be a menu option that allows the inventory to be modified. i.e. add inventory quantities, change price/cost, change dates, etc.
•You will use structs and an array to organize the data in the program. Your struct must contain at least the following kinds of information:
Minimum of 2 strings (character arrays)
Suggestions include: item name, manufacturer, etc
Minimum of 2 integers – 1 must be product id
Product id, qty in stock
Minimum of 2 double values
Suggestions include: cost, price, average inventory:
When you add new item the program will ask the user for each of the fields on a separate line.
When you delete an item from inventory the program will ask you for the integer id of the entry to be deleted, locate the entry in the array and remove all of the data for that entry. – The list does not need to be sorted – to remove an entry, you may move the last item in the list to the location of the deleted entry
When you display the records on the screen, all of the information stored for each entry will be labeled and displayed.
Creating a current inventory report copies the current entries in the array to an output file. This must include labeling all of the information so that it is clear what information is being provided.
Clearing the records deletes all of the information in the array.
Instructions:
You should useat least 8 user-defined functions (plus main) to appropriately break the problem up into smaller pieces.
Your program must start up with at least 5 valid records. These records must be “hard coded” in your program file. (This can be done in one of your user-defined functions)
You should use function prototypes and NO global variables (20 point penalty)
You should use a #define to set the upper bound of the list to 50 entries.
Your code should be well designed, well commented and written with good style.
You should use at least 8 user-defined functions (plus main) to appropriately break the problem up into smaller pieces.
Your program must start up with at least 5 valid records. These records must be “hard coded” in your program file. (This can be done in one of your user-defined functions)
You should use function prototypes and NO global variables (20 point penalty)
You should use a #define to set the upper bound of the list to 50 entries.
Your code should be well designed, well commented and written with good style.
Explanation / Answer
#include <iostream.h>
#include <conio.h>
class staff
{
protected:
int code;
char name[20];
public:
void getstaff(void)
{
cout<<" Enter code :-";
cin>>code;
cout<<"Enter name :-";
cin>>name;
}
void dispstaff(void)
{
cout<<" NAME :-"<<name;
cout<<" CODE :-"<<code;
}
};
class teacher : public staff
{
char sub[20];
char pub[20];
public:
void create(void)
{
getstaff();
cout<<"Enter Subject :-";
cin>>sub;
cout<<"Enter Publication :-";
cin>>pub;
}
void display(void)
{
dispstaff();
cout<<" SUBJECT :-"<<sub;
cout<<" PUBLICATION:-"<<pub;
}
};
class officer : public staff
{
char grade;
public:
void create(void)
{
getstaff();
cout<<"Enter Grade :-";
cin>>grade;
}
void display(void)
{
dispstaff();
cout<<" GRADE :-"<<grade;
}
};
class typist : public staff
{
float speed;
public:
void gettypist(void)
{
getstaff();
cout<<"Enter speed (wpm):-";
cin>>speed;
}
void disptypist(void)
{
dispstaff();
cout<<" SPEED :-"<<speed;
}
};
class casual : public typist
{
float dailywages;
public:
void create(void)
{
gettypist();
cout<<"Enter Daily Wages :-";
cin>>dailywages;
}
void display(void)
{
disptypist();
cout<<" DAILY WAGES:-"<<dailywages;
}
};
void main()
{
clrscr();
teacher o1t[10];
casual o1c[10];
officer o1o[10];
int choice,i;
char test;
while(1)
{
int count;
start:
clrscr();
cout<<" =====EDUCATION INSTITUTION DATABASE===== ";
cout<<"Choose Category of Information ";
cout<<"1) Teachers ";
cout<<"2) Officer ";
cout<<"3) Typist ";
cout<<"4) Exit ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case 1 : while(1)
{
clrscr();
cout<<" =====TEACHERS INFORMATION===== ";
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case 1 : for(count=0,i=0;i<10;i++)
{
cout<<endl;
o1t[i].create();
count++;
cout<<endl;
cout<<" Are you Interested in entering data ";
cout<<"Enter y or n:-";
cin>>test;
if(test=='y' || test=='Y')
continue;
elsegoto out1;
}
out1:
break;
case 2 : for(i=0;i<count;i++)
{
cout<<endl;
o1t[i].display();
cout<<endl;
}
getch();
break;
case 3 : goto start;
default: cout<<" Enter choice is invalid try again ";
}
}
case 2 : while(1)
{
clrscr();
cout<<" =====OFFICERS INFORMATION===== ";
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case 1 : for(count=0,i=0;i<10;i++)
{
cout<<endl;
o1o[i].create();
count++;
cout<<endl;
cout<<" Are you Interested in entering data ";
cout<<"Enter y or n:-";
cin>>test;
if(test=='y' || test=='Y')
continue;
elsegoto out2;
}
out2:
break;
case 2 : for(i=0;i<count;i++)
{
cout<<endl;
o1o[i].display();
cout<<endl;
}
getch();
break;
case 3 : goto start;
default: cout<<" Invalid choice try again ";
}
}
case 3 : while(1)
{
clrscr();
cout<<" =====TYPIST INFORMATION===== ";
cout<<" Choose your choice ";
cout<<"1) Create ";
cout<<"2) Display ";
cout<<"3) Jump to Main Menu ";
cout<<"Enter your choice:-";
cin>>choice;
switch(choice)
{
case 1 : for(count=0,i=0;i<10;i++)
{
cout<<endl;
o1c[i].create();
count++;
cout<<endl;
cout<<" Are you Interested in entering data ";
cout<<"Enter y or n:-";
cin>>test;
if(test=='y' || test=='Y')
continue;
elsegoto out3;
}
out3:
break;
case 2 : for(i=0;i<count;i++)
{
cout<<endl;
o1c[i].display();
cout<<endl;
}
getch();
break;
case 3 : goto start;
default: cout<<" Invalid choice try again ";
}
}
case 4 : goto end;
}
}
end:
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.