c++ - Reading strings and integers into arrays from .txt file -


i novice programmer , i'm having trouble 1 of exercises. need create program reads student information (ssn, first & last name, test score) .txt file called "students.txt", , uses 4 global parallel arrays store student information. i'm required use int array store ssn, string array store first names, string array store last names, , double array store scores. operations include listing students' info how appears:

   ssn     last-name  first-name score 628130189  james,     paul        92.0 237698211  cook ,     daniel      86.0 201895367  garza,     melessa     78.0 491066285  barbara,   jessica     62.0 168606868  bruce,     elizabeth   90.0  378205732  lee,       sarah       91.5 118453900  brian,     david       87.0 583192186  garza,     cody        92.0 226665118  lewis,     gage        78.0 175382843  collins,   james       69.5 816231095  white,     ann         88.5 376651608  jackson,   mark        72.0 508234567  freeman,   mark        86.0 763211099  william,   jack        52.0 286204723  rodriguez, john        69.5 

but of course, .txt file ssn first-name last-name , score unaligned , separated comas. have display student highest score, , lowest, , average of scores using "void". dont know how read file in first place , make data it's organized columns.

also...i have report error message , exit program if file cannot found? otherwise, program should display main menu follows allow user complete listed operations.

here's have far:

#include <iostream> #include<iomanip> #include<fstream> using namespace std;   void mainmenu(); /* void sort_name();(); void sort_ssn(); void sort_score (); */ void average();  void lowest_score(); void highest_score(); void open_file();  const int totnum = 15; //my global variables int ssn[totnum]; string fname [totnum]; string lname [totnum]; double score [totnum];  int main () {       char choice;      ifstream fin;     fin.open("students.txt")  (1=0; <= totnum; i++)//this i'm stuck {      ?????    } {   mainmenu(); //calling main menu funtion     cin >> choice;     cin.ignore (10, '\n'); //spacing     switch(choice) // switch statment multiple cases flexibility     {         case 'l':         case 'l':         case '1': open_file(); break;          /*         case 'h':         case 'h':            case '2': highest_score(); break;          case 'o':         case 'o':         case '3': lowest_score(); break;         case 'a':         case 'a':         case '4': average(); break;          case 's':         case 's':            case '5': sort_ssn(); break; //operation 5-7 bonus work         case 'n':         case 'n':         case '6': sort_name(); break;         case 'c':         case 'c':          case '7': sort_score();break;         */         case 'e':         case 'e':            case '0': break;         default: cout << "wrong choice!" << endl; break;         }     cout << endl; }   while(choice != '0'); // && choice !='e' && choice!='e')     } void mainmenu() //output main menu { cout << "main menu (assignment 8)" << endl; cout << "1. list students' infromation (l)" << endl; /* cout << "2. find highest score (h)" << endl; cout << "3. find lowest score (o)" << endl; cout << "4. calculate average score (a)" << endl;  cout << "5. sort students ssn (s)" << endl; cout << "6. dort students name (n)" << endl; cout << "7. sort students score (c)" << endl; */ cout << "0. exit" << endl; cout << "please select option: "; } 

it doesn't make sense that's why i'm desperate help...


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -