complete this function

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
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

void ReadData(int[],string[],string[],float[],int[]);
void DisplayMenu();
int main()
{
	int SID[50];
	string FNAME[50];
	string MAJOR[50];
	int HRS[50];
	float GPA[50];
	
	
	
	
	ReadData(SID,FNAME,MAJOR,GPA,HRS);
	
	DisplayMenu();

		return 0;
	
}
////////////////////////////////////
///////////////////////////////////
void ReadData(int SID[],string FNAME[],string MAJOR[],float GPA[],int HRS[])
{
	ifstream infile;

	infile.open("studinput.txt");
	
	while (!infile.eof())
	{
		infile >> SID[i] >> FNAME[i] >> MAJOR[i] >> GPA[i] >> HRS[i];
		
		i++;
	}
	infile.close();
	
}
/////////////////////////////////////////
////////////////////////////////
void DisplayMenu()// what the parameter and argument i must include for this function
{
	int option;
	cout << "enter your number from 1 to 4" << endl;
	cin >> option;
.
.
.
.
. // what i can do int this area
}


the output looks like this


1.	Find Student Data
2.	Add New Student Data
3.	Delete Student Data
4.	Stop and Print the Report

Enter your option : 1  //or 2 or 3 or 4
Hey dude,

you can do it so:

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
int main ( )
{
	switch(DisplayMenu())
	{
	case 1:
		FindStudent() ;
	case 2:
		AddNewStudent() ;
	case 3:
		DeleteStudent() ;
	case 4:
		StopAndPrint() ;
	default:
		std::cerr << "[ERROR] INVALID OPTION >.< [SELF-DESTRUCT] *BOOM*" << std::endl ;
	}
}

std::size_t DisplayMenu()
{
	std::size_t Option ;
	std::cout << "1.\tFind Student Data" << std::endl
			<< "2.\tAdd New Student Data" << std::endl
			<< "3.\tDelete Student Data" << std::endl 
			<< "4.\tStop and Print the Report" << std::endl << std::endl << std::endl
			<< "Enter your option: " ;
	std::cin >> Option;
	return Option ;
}


have fun dude (:
Last edited on
thank you dude (you also)

but u forget break; in swith(case);

1
2
3
4
5
6
7
8
9
10
11
12
13
switch(DisplayMenu())
	{
	case 1:
		FindStudent() ; break;
	case 2:
		AddNewStudent() ; break;
	case 3:
		DeleteStudent() ; break;
	case 4:
		StopAndPrint() ; break;
	default:
		std::cerr << "[ERROR] INVALID OPTION >.< [SELF-DESTRUCT] *BOOM*" << std::endl ;
	}
oh nooo :( this is embarrassing!!

Sorry !
What is the point of i++ on line 39? I don't think the var i does anything, unless I completely missed something.

Also I would do it with returning int, but maybe I am just old fashioned :)

Then you can just tell them to input the option, then return it after checking validity if needed.
thanx soko
you might get a problem with your while look on line 35 as your i variable isn't declared anywhere i can find.
Topic archived. No new replies allowed.