manipulate the menu

My program is supposed to display the menu, then prompt you to enter in the new information. I only want the original menu to show. after you enter in the new information i want the prompt to disappear and only the menu to remain so i can enter another option and i cant figure out how to do that. so far the program exits after the 1st input. here is my current 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
#include <iostream> 
#include <iomanip>

using namespace std;

int main()
{
    char    answer;
    string  name = "none", major = "none", email = "none@";
    int     id = 0;
    double  gpa = 0;
    
    
    cout << fixed << showpoint;
    cout << left;
    
    cout << endl << endl << endl << setw(3) << " " << "Edit Student Menu" << endl << endl;
    cout << setw(3) << "n" << "change name" << endl;
    cout << setw(3) << "i" << "change id" << endl;
    cout << setw(3) << "m" << "change major" << endl;
    cout << setw(3) << "e" << "change email" << endl;
    cout << setw(3) << "g" << "enter new gpa" << endl;
    cout << setw(3) << "r" << "return to main menu" << endl << endl;
    cout << "enter choice: -";
    
    cin >> answer;
        
    if (answer == 'n')
    {
        cout << "new name?" << endl;
        cin >> name;
       
    }
    
    else if (answer == 'i')
    {
        cout << "new id?" << endl;
        cin >> id;
    }
    
    else if (answer == 'm')
    {
        cout << "new major?" << endl << setw(3) << " " << "approved majors" << endl << "CS" << endl << "math" << endl << "mech eng" << endl;
        cin >> major;
    }
    
    else if (answer == 'e')
    {
        cout << "new email?" << endl;
        cin >> email;
    }
    
    else if (answer == 'g')
    {
        cout << "new gpa?" << endl;
        cin >> gpa;
    }
    
    else if (answer == 'r')
    {
        cout << name << "  " << "#" << id << endl << setprecision(1) << gpa << " as a " << major << endl << "email: " << email << endl;
    }
    
    system("pause");
    return 0;   
}    


please help thanks
I know the desire to make things pretty very well, but you have to resist the urge sometimes. In this case, don't worry about making things disappear. It is a normal terminal program, so it doesn't have those powers.

Your program should be organized something like this
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
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

char menu()
  {
  // if you want to clear the screen, output 50 or so newlines
  cout << string( 50, '\n' );

  // display the menu
  // get input
  // return the input
  }

int main()
  {
  // variables and stuff here

  bool done = false;
  while (!done)
    switch (tolower( menu() ))
      {
      case 'n': ...
      case 'i': ...
      case 'r': done = true; break;
      default: ...
      }

  return 0;
  }


Hope this helps.
Next line below int main() write: " start:"
Line above "system("pause") write:" goto start;"
Of couse you could always use a loop.
closed account (z05DSL3A)
buffbill wrote:
Next line below int main() write: " start:"
Line above "system("pause") write:" goto start;"
Of couse you could always use a loop.


You should avoid using goto wherever possible, Duoas's solution would be proffered in this situation.
Topic archived. No new replies allowed.