CODE
//
//if select Math or SCIE as a major display all studrec associated
//studentidandmajor ex 3333MATH or 4445SCIE
#include<iostream>
#include<fstream>
#include<string>
//Function declaration
void PutMenu();
void GetData(int *, const char *);
//void DisplayMajor(int[], string[]);
int MenuChoice();
using namespace std;
// This program implements an interactive menu with the
// following options:
// 1 - Add records to the file
// 2 - Display student records for a major
// 3 - Exit from the program
int student_ID[4];
const char major_Code[4];
void main()
{
//open output file
ofstream fout;
fout.open("C://student.txt");
if (fout.fail())
{
cerr << "Output file opening failed.\n";
exit(1);
}
MenuChoice();
int choice, a[4];
string b;
do //Repeat procedure until choice is 3
{
PutMenu();
choice = MenuChoice();
switch (choice)
{
case 1:
GetData(a, B);
break;
case 2:
// DisplayMajor(student_ID, major_Code);
break;
case 3:
exit(1);
default:
cout << "Invalid choice..." << endl;
}
} while (choice != 3);
}// end main function;
// Gets data for the student id and Major
void GetData(int student_ID[], const *char major_Code[])
{
int a;
int b;
char *major_CodePtra = "MATH";
char *major_CodePtrb = "SCIE";
cin >> a;
cin >> b;
}
void PutMenu()
{
cout << "MENU" <<endl;
cout << endl << endl <<endl;
cout << " 1 - Enter ID and Enter Major (CINS or CMSC)\n";
cout << " 2 - Enter Major Code to display all student records with that code:\n";
cout << " 3 - Exit and save records to file\n";
}
int MenuChoice()
{
cout << "choice: ";
int ch;
cin >> ch;
switch (ch)
{
case '1':
return 1;
case '2':
return 2;
case '3':
return 3;
}
}
*edit: Please use code tags in the future. Thanks!
This post has been edited by Martyr2: 10 Dec, 2007 - 04:01 PM