the output looks like just cout statements.
you need menus within a menu.
you may try a switch...
1 2 3 4 5 6 7 8 9 10
do
main_menu();
cin >> choice;
switch choice
{
case 1: initialize_menu(); break;
case 2: create_records(); break;
...
default: cout << invalid choice message
}
and where necessary the sub menus work exactly like that.. create_records will have the exact same structure as the above --- call something to print the menu, then switch to handle the input and populate your data structure. you can have a for loop instead of while in this one because you know how many times it will execute.
but the idea is to break it down into simple blocks that call functions to handle the menus, so the menu code is small, easy to read, easy to modify, etc. If you try to do the work in the menus (eg in the switch cases) it can quickly bloat up and be hard to work with.
So the switch is used for a sub menu?
How do I quit the sub menu back to the main menu?
Also how do I put a new input and saved onto the array as a new saved record like question 5 has mentioned
yes, the main menu's switch activates the sub-menu.
the sub menu ends ... the create record one ends after a counter. the user says they want to put in 5, so you let them put in 5 and pop back out. other sub menus may need a choice to exit back to the main menu. since its driven by function calls, when the main menu calls the sub menu, the sub menu ends, you are back where you were in main, which should (if the switch is done right) just restart a loop of the main menu again from scratch.
usually prefer to write directly -- so each record, you write into array[index].something directly. No sense in loading up a middle man record and then copying all that to the real destination...
however with the data validation, that may still happen .. read into a string, validate it, if its good, write the data into the array (converting type as needed). This is sort of a design choice in how you store the data and how you validate it and so on.
no.
break is used on switch cases if you don't want to fall through to the next case(s)
this may end the switch, which may then be the end of the function. It is the function ending that returns back to where it was called from. But as I showed you, the switches are probably in some sort of a loop. If you need to stop that and get back to main, you need a way out. The most straightforward way to do that is just a 'return' statement.
you were going to loop anyway (I said that up there somewhere).
the while does not replace the switch.
a bunch of if/else conditions can replace the switch, if you prefer that. Its fine to do that.
The best way to get help if you are stuck is to post some code, say what it is supposed to do, what is wrong with it, and see what we can tell you.
Seeplus and Jonnin, I have post my code on the above, already done the sub menu with while which I think it was easier but my while can only quit once on sub men to the main menu and I cant use the sub menu again from the main menu u when I typed 4 on the sub menu, meanwhile if i type below than 4 then it will quit to the main menu and it can repeat using the sub menu again from the main menu
Still struggling to do question 5 of creating new array spaces from the element with input
you do not create new array elements. arrays are fixed size and it says 10 max.
IF choice is 1 put in junk blah blah
ELSE IF CHOICE IS 2 don't fill in defaults, user provides.
the records already exist. you are just filling them in.
int x[10]; //10 integers exist, with nonsense data in them
x[3] = 42; //put something into it.
If the choice is 2 ... After that, a sub-menu should be displayed for the end user to input ....
@seeplus, Jonnin, I kinda figured about how to add 10 records but still dont know how to add the sub menu to allow to input to store these new arrays, do I have to use cin.getline() to input the email address, name and phone number into these new array records from question 5?
Not to mention I have to create another submenu to make a search for the new records for option 3 that I had created from the input according to the assignment questions 6 of the google docs, can you help? Assignment is due soon