while loop with a switch attempting to run a looped menu

I am trying to create a menu where the patient number is the first thing that is asked every time and continues through my menu functions and repeats until i type in -1 for pantientNumber to exit. i cant figure out how to enter a loop that is contingent on patientNumber without entering patientNumber before the loop.

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
if(outputFile)
	{
		int patientNumber;
		double totStay;
	 
		
			cout << "Patient Number: ";
			cin >> patientNumber;
			while ( ( patientNumber = cin.get() ) != EOF)
			{
				
				char inOutPatient;
				cout << "Enter I (in-patient) or O (out-patient):  ";
				cin >> inOutPatient;
				switch (inOutPatient)
				{
				case 'I' :
				case 'i' :
							totStay = inPatient();
							cout << "Patient Number: " << patientNumber << endl
								 << "The total charges are $" << totStay;
							break;
				case 'O' :
				case 'o' :
							break;
				default: 
							cout << "Please enter I or O:";
							cin >> inOutPatient;
							break;
				}
			++numberOfPatients;
			}
			
		
		
	}

look into the do{} while()
this will allow you to put the print statement at the top then have the repeat condition at the bottom.
Topic archived. No new replies allowed.