7-11 program need your help
Jul 14, 2011 at 8:56am UTC
i need to finish it badly guys..
i need a "search" all that i have add in the output
here my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
#include <iostream.h>
#include <string.h>
#include<stdlib.h>
using namespace std;
struct record{
string jeem;
string ablir;
string ja;
string emy;
string nelly;
}rec[20];
int wert = 0;
int buds;
int x,y;
void add();//add
void edt();//edit
void srch();//search
void dis();//display
int main(){
while (buds != 5){
cout<<"--COMMAND--\n" ;
cout<<"1. Add\n" ; cout<<"2. Edit\n" ;
cout<<"3. Search\n" ; cout<<"4. Display\n" ;
cout<<"5. Exit\n" ; cout<<"Enter Choice Letter: " ;
cin>>buds;
if (buds > 5){
cout<<"Invalid Input" <<endl;
system("pause" );
system("cls" );
main();
}
else {
switch (buds){
case 1:{add();}break ;
case 2:{edt();}break ;
case 3:{srch();}break ;
case 4:{dis();
system("pause" );
system("cls" );
main();
}break ;
}
}
}
return 0;
}
void add(){//add
system("cls" );
cout<<"Product no.:" ;
cin>>rec[wert].jeem;
cout<<"Product name:" ;
cin>>rec[wert].ablir;
cout<<"Price:" ;
cin>>rec[wert].ja;
cout<<"Quantity:" ;
cin>>rec[wert].emy;
cout<<"save!" <<endl;
system("pause" );
wert++;
system("cls" );
main();
}
void edt(){//edit
system("cls" );
int toEdit;
for (y=0; y<wert; y++){
cout<<"[" <<
y<<"]\nProduct no.: " <<rec[y].jeem
<<"\nProduct name: " <<rec[y].ablir
<<"\nPrice: " <<rec[y].ja
<<"\nQuantity: " << rec[y].emy<<"\n" ;
}
cout<<"Choose to edit: \n" ;
cin>>toEdit;
cout<<"Enter new Product no.: \n" ;
cin>>rec[toEdit].jeem;
cout<<"Enter new Product name: \n" ;
cin>>rec[toEdit].ablir;
cout<<"Enter new price: \n" ;
cin>>rec[toEdit].ja;
cout<<"Enter new quantity: " ;
cin>>rec[toEdit].emy;
cout<<"Contact successfully changed!\n" ;
system("cls" );
main();
}
void srch(){//search
system("cls" );
system("pause" );
system("cls" );
main();
}
void dis(){//display
system("cls" );
for (int x = 0; x < wert; x++){
cout<<"Record" <<x;
cout<<":" <<"\n\n" ;
cout<<"Product no.: " <<rec[x].jeem;
cout<<"\n" ;
cout<<"Product name: " <<rec[x].ablir;
cout<<"\n" ;
cout<<"Price: " <<rec[x].ja;
cout<<"\n" ;
cout<<"Quantity: " <<rec[x].emy;
cout<<"\n" ;
}
}
Jul 14, 2011 at 9:39am UTC
@jeem,
Could you explain the detail "i need a "search" all that i have add in the output
" ? I think we can't catch you ! thanks
Jul 14, 2011 at 10:31am UTC
Don't call main. Loops are for repetition.
I don't know what you want to search for, but the function will have a string input, a for loop and a == comparison between the input string and one of record members.
Topic archived. No new replies allowed.