i need help with my project
its a phone book project with iostream and the menu is switch case but when i choose a choice in the menu it just displays the menu again
#include<iostream>
#include<windows.h>
using namespace std;
void start();
int manu();
int k=0;
string name[5];
string no[5];
string lastname[5];
int check=0;
int Total_contacts=0;
void addcontacts(){
cout<<"\t\t\t\t\t\t Name :";
cin>>name[k];
cout<<"\t\t\t\t\t\t lastname :";
cin>>lastname[k];
cout<<"\t\t\t\t\t\t Phone no :";
cin>>no[k];
k++;
Total_contacts++;
}
void displaycontacts(){
int check2=0;
for(int i=0; i<5;i++)
{
if(name!="\0")
cout<<"\t\t\t\t\t Name :"<<name<<"lastname:"<<lastname<< " Phone :"<<no<<endl;
check2++;
}
if(check2==0)
{
cout<<"\t\t\t\t\t";
}
}
void searchbylastname(){
string temp;
cout<<"\t\t\t\t\tlastname : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==lastname)
{
cout<<"\t\t\t\t\tlastname is Found\n";
cout<<"\t\t\t\t\tName : "<<name<<"lastname:"<<lastname<<" Phone : "<<no<<endl;
check2++;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void searchbyname(){
string temp;
cout<<"\t\t\t\t\tName : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tName is Found\n";
cout<<"\t\t\t\t\tName : "<<name<<" Phone : "<<no<<endl;
check2++;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void update(){
string temp,temp2,temp3,temp4;
cout<<"\t\t\t\t\tName : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tNew Name : ";
cin>>temp2;
cout<<"\t\t\t\t\tNew Number : ";
cin>>temp3;
cout<<"\t\t\t\t\tNew lastname : ";
cin>>temp4;
name=temp2;
no=temp3;
lastname=temp4;
check2++;
cout<<"\t\t\t\t\tba movafaghiat taghir kard ";
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void del(){
string temp;
cout<<"\t\t\t\t\tFor Delete Enter Name : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tDeleted Successfully\n";
cout<<"\t\t\t\t\tName : "<<name<<"lastname:"<<lastname<<" Phone : "<<no<<endl;
name="\0";
no="\0";
lastname="\0";
check2++;
Total_contacts--;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void delall(){
cout<<"\t\t\t\t\t ba movafaghiat pak shodand\n";
for(int i=0;i<k;i++)
{
name="\0";
no="\0";
}
k=0;
Total_contacts=0;
}
void displaycontactnum(){
cout<<"\t\t\t\t\ttedad tamame mokhatabin : "<<Total_contacts<<endl;
}
int manu()
{
cout<<"\n\n\n\n\n";
cout<<"\t\t\t\t\t-----------------------------------------------\n";
cout<<"\t\t\t\t\t-----------------------------------------------\n";
cout<<"\t\t\t\t\t| daftar telfon |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
cout<<"\t\t\t\t\t| |\n";
cout<<"\t\t\t\t\t| [1] ezafe kardan mokhatabin |\n";
cout<<"\t\t\t\t\t| [2] tamame mokhatibn ra neshan bede |\n";
cout<<"\t\t\t\t\t| [3] jostoju bar asase name khanevadegi|\n";
cout<<"\t\t\t\t\t| [4] jostoju bar asase esm |\n";
cout<<"\t\t\t\t\t| [5] taghir ettelat |\n";
cout<<"\t\t\t\t\t| [6] pak kardan |\n";
cout<<"\t\t\t\t\t| [7] pak kardane hame |\n";
cout<<"\t\t\t\t\t| [8] tedad mokhatab |\n";
cout<<"\t\t\t\t\t| |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
cout<<"\t\t\t\t\t| [9] khoruj |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
int a;
cin>>a;
do
{
// Add contacts
if(check==1)
{
addcontacts();
}
//Diplay contacts
else if (check==2)
{
displaycontacts();
}
//Search by lastname
else if(check==3)
{
searchbylastname();
}
//Search By Name
else if(check==4)
{
searchbyname();
}
// Update
else if(check==5)
{
update();
}
// delete
else if(check==6)
{
del();
}
// delete All
else if(check==7)
{
delall();
}
// Diplay numbers of contacts
else if(check==8)
{
displaycontactnum();
}
check=manu();
}while(check!=9);
return a;
system("cls");
}
int main()
{
check=manu();
manu();
}
its a phone book project with iostream and the menu is switch case but when i choose a choice in the menu it just displays the menu again
#include<iostream>
#include<windows.h>
using namespace std;
void start();
int manu();
int k=0;
string name[5];
string no[5];
string lastname[5];
int check=0;
int Total_contacts=0;
void addcontacts(){
cout<<"\t\t\t\t\t\t Name :";
cin>>name[k];
cout<<"\t\t\t\t\t\t lastname :";
cin>>lastname[k];
cout<<"\t\t\t\t\t\t Phone no :";
cin>>no[k];
k++;
Total_contacts++;
}
void displaycontacts(){
int check2=0;
for(int i=0; i<5;i++)
{
if(name!="\0")
cout<<"\t\t\t\t\t Name :"<<name<<"lastname:"<<lastname<< " Phone :"<<no<<endl;
check2++;
}
if(check2==0)
{
cout<<"\t\t\t\t\t";
}
}
void searchbylastname(){
string temp;
cout<<"\t\t\t\t\tlastname : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==lastname)
{
cout<<"\t\t\t\t\tlastname is Found\n";
cout<<"\t\t\t\t\tName : "<<name<<"lastname:"<<lastname<<" Phone : "<<no<<endl;
check2++;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void searchbyname(){
string temp;
cout<<"\t\t\t\t\tName : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tName is Found\n";
cout<<"\t\t\t\t\tName : "<<name<<" Phone : "<<no<<endl;
check2++;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void update(){
string temp,temp2,temp3,temp4;
cout<<"\t\t\t\t\tName : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tNew Name : ";
cin>>temp2;
cout<<"\t\t\t\t\tNew Number : ";
cin>>temp3;
cout<<"\t\t\t\t\tNew lastname : ";
cin>>temp4;
name=temp2;
no=temp3;
lastname=temp4;
check2++;
cout<<"\t\t\t\t\tba movafaghiat taghir kard ";
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void del(){
string temp;
cout<<"\t\t\t\t\tFor Delete Enter Name : ";
cin>>temp;
int check2=0;
for(int i=0;i<5;i++)
{
if(temp==name)
{
cout<<"\t\t\t\t\tDeleted Successfully\n";
cout<<"\t\t\t\t\tName : "<<name<<"lastname:"<<lastname<<" Phone : "<<no<<endl;
name="\0";
no="\0";
lastname="\0";
check2++;
Total_contacts--;
}
}
if(check2==0)
{
cout<<"\t\t\t\t\t in nam miane mokhatabin namojud ast\n";
}
}
void delall(){
cout<<"\t\t\t\t\t ba movafaghiat pak shodand\n";
for(int i=0;i<k;i++)
{
name="\0";
no="\0";
}
k=0;
Total_contacts=0;
}
void displaycontactnum(){
cout<<"\t\t\t\t\ttedad tamame mokhatabin : "<<Total_contacts<<endl;
}
int manu()
{
cout<<"\n\n\n\n\n";
cout<<"\t\t\t\t\t-----------------------------------------------\n";
cout<<"\t\t\t\t\t-----------------------------------------------\n";
cout<<"\t\t\t\t\t| daftar telfon |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
cout<<"\t\t\t\t\t| |\n";
cout<<"\t\t\t\t\t| [1] ezafe kardan mokhatabin |\n";
cout<<"\t\t\t\t\t| [2] tamame mokhatibn ra neshan bede |\n";
cout<<"\t\t\t\t\t| [3] jostoju bar asase name khanevadegi|\n";
cout<<"\t\t\t\t\t| [4] jostoju bar asase esm |\n";
cout<<"\t\t\t\t\t| [5] taghir ettelat |\n";
cout<<"\t\t\t\t\t| [6] pak kardan |\n";
cout<<"\t\t\t\t\t| [7] pak kardane hame |\n";
cout<<"\t\t\t\t\t| [8] tedad mokhatab |\n";
cout<<"\t\t\t\t\t| |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
cout<<"\t\t\t\t\t| [9] khoruj |\n";
cout<<"\t\t\t\t\t------------------------------------------------\n";
int a;
cin>>a;
do
{
// Add contacts
if(check==1)
{
addcontacts();
}
//Diplay contacts
else if (check==2)
{
displaycontacts();
}
//Search by lastname
else if(check==3)
{
searchbylastname();
}
//Search By Name
else if(check==4)
{
searchbyname();
}
// Update
else if(check==5)
{
update();
}
// delete
else if(check==6)
{
del();
}
// delete All
else if(check==7)
{
delall();
}
// Diplay numbers of contacts
else if(check==8)
{
displaycontactnum();
}
check=manu();
}while(check!=9);
return a;
system("cls");
}
int main()
{
check=manu();
manu();
}