Hi I am trying to make a nursery registration form for an assignment at uni and have hit a stumbling block. I have written the functions but dont really know what to declare them as. Could anyone help.
#include <cstdlib>
#include <iostream>
#include <fstream>
using namespace std;
int menu(); //creating a function called menu
Enter_child_dets();
Enter_parent_dets();
Display_child_dets();
Search_parent();
help();
int main(int argc, char *argv[])
{
int users_choice; users_choice=menu();
menu();
switch (users_choice)
{
case 1://close will break automatically
break;
case 2: Enter_child_dets();
break;
case 3: Enter_parent_dets();
break;
case 4: Display_child_dets();
break;
case 5: Search_parent();
break;
case 6: help();
break;
default: cout<<"You made an invalid choice";
}
system("PAUSE");
return EXIT_SUCCESS;
//-----------------------------------------------------------------------------------------------------------------------
}
int menu()
{
int users_choice;
cout<<"=====Nursery Registration System====="<<endl<<endl<<endl;
cout<<"\t1 - Quit"<<endl;
cout<<"\t2 - Enter Child Details"<<endl;
cout<<"\t3 - Enter Parent Detals"<<endl;
cout<<"\t4 - Display Children Details"<<endl;
cout<<"\t5 - Search Parent"<<endl;
cout<<"\t6 - Help Information"<<endl<<endl;
cout<<"\tPlease make your choice: ";
cin>>users_choice;//create a variable to send a value to users_choice
return users_choice;//return choice
}
//--------------------------------------------------------------------------------------------------------
Enter_child_dets()//enter child name, enter child age, save it to a text file.
{
{
string child_name;
int child_age;
child_name = child_name();
child_age = child_age();
save_child(child_name, child_age);
}
string child_name()
{
string child_name; child_name="";
do
{
cout<<"Enter Name of Child: ";
cin>>child_name;
}
while(child_name.length <1 || child_name.length >50)//length of name has to be be >1 or <50
return child_name;
}
int child_age();
{
int child_age
do
{
cout<<"Enter Age of Child: ";
cin>>child_age;
}
while (child_age <1 || child age > 5;
return child_age;
}
save_child(string child_name, int child_age) //copying information from each variable as opposed to
{
ofstream myfile;
myfile.open("child.txt", ios ::app);
myfile<<child_name<< " , "<<child_age<<endl;
myfile.close;
}
}
//-----------------------------------------------------------------------------------------------------------------
Enter_parent_dets();//enter child name, enter child age, save it to a text file.
{
{
string parents_name;
int parents_tel;
parents_name = parents_name();
parents_tel = parents_tel();
save_parent(parents_name, parents_tel);
}
string parents_namee()
{
string parents_name; parents_name"";
do
{
cout<<"Enter Name of parent: ";
cin>>parents_name;
}
while(parents_name.length <1 || parents_name.length >50)//length of name has to be be >1 or <50
return parents_name;
}
int parents_tel();
{
int parents_tel
do
{
cout<<"Enter Telephone Number: ";
cin>>parent_tel;
}
while (parents_tel <1 || parents_tel > 5;
return parents_tel;
}
save_child(string parent_name, int parent_tel) //copying information from each variable as opposed to
{
ofstream myfile;
myfile.open("guardian.txt", ios ::app);
myfile<<parent_name<< " , "<<parent_tel<<endl;
myfile.close;
}
}
//-------------------------------------------------------------------------------------------------------------
Display_child_dets()
{
long begin,end;
ifstream myfile ("child.txt");
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
cout << "size is: " << (end-begin) << " bytes.\n";
return Display_child_dets;
}
//----------------------------------------------------------------------------------------------
Search_parent()
{
{
int enter_id
enter_id()=enter_id();
find_parent(enter_id);
}
int enter_id
{
cout<<"Enter childs ID";
cin>>enter_id;
return enter_id
}
find_parent(enter_id);
{
ifstream myfile("guardian.txt);
if myfile.is_open()
{
while(!myfile.eof())
{
line_number++;
getline(myfile, line);
if(line_number==child_id){break;}
}
if(line_numbre==child_id)
{
cout<<line<<endl;
myfile.close();
}
else cout<<"unable to read file";
else =||=
}
else cout<<"unable to read file";
}
}
//------------------------------------------------------------------------------------------
}
void help()
{
cout << " Help "<<endl;
cout<< " ---- "<<endl;
cout << "\tTyping a number will have a specific outcome." << endl;
cout << "\tTyping 1 quits the program, and 2 lets you enter a childs name" << endl;
cout << "\tif you type 3, the program lets you enter the parents name." << endl;
cout << "\twhere as 4 will display all the children" << endl;
cout << "\t5 will let you search for the childs parent" <<endl;
cout << "\tand 6 which you have already pressed opens up help" <<endl<<endl<<endl<<endl<<endl;
}