Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6766483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:50:11+00:00 2026-05-26T14:50:11+00:00

I have a program that takes in a data file of students that have

  • 0

I have a program that takes in a data file of students that have a COSID between 100 and 200 and the courses they are enrolled in. It looks like : 100
Greg
Samson
3
COS301
COS431
COS490
120
Jo Ann
Lyons
0
. I have a dynamic array that holds all the courses that the student is taking. The problem that I am having is I am asked to print other people in a paticular class when a course ID is inputed using this prototype: void printList (ostream& out, FlexArray<Student> majors, int cosID, string course);

I’m not really sure how to create the function to search the array for this protype. I tried to intilize the array so all the COSID’s are -1 so when trying to search I should be more easily able to find the elements that have information, but can’t get that work either. Here is my code thus far T:

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include "templates.h"


using namespace std;

struct Student {

  int COSID;
  string fname;
  string lname;
  int totCourses;
   string * coursearr;
};
void printList (ostream& out,  FlexArray<Student> majors,  int cosID, string course);

int main(){
    Student s; // Object for struct student
    int searchCOSID; //varible to find COS id
    int Loopcheck = -1; //break loop variable
    string LoopCOSID = ""; //break loop variable
    FlexArray<Student> fa(100,200); //object for flex array setting Upper bounds to 200 and lower bounds to 100

    //Initilize the flexarray cosid to -1;
    for(int i=100; i<=200; i++){
        fa[s.COSID = -1];
    }
    cout << fa[105].COSID;
    char c;


    ifstream  fin;              // declare input file stream object 
    fin.open ("a5.txt");
    fin >> s.COSID;
    fin.get(c);
    getline(fin, s.fname);
    getline(fin, s.lname);
    fin >> s.totCourses;
    while(!fin.fail()){
        s.coursearr = new string[s.totCourses];
        if(s.totCourses > 0){
        for(int i=0; i<s.totCourses; i++){
            fin >> s.coursearr[i];
        }
        }
        fa[s.COSID] = s;
        fin >> s.COSID;
        fin.get(c);
        getline(fin, s.fname);
        getline(fin, s.lname);
        fin >> s.totCourses;
    }



        cout << "\nEnter your COS ID: ";
        cin >> searchCOSID;
        Student currstudent = fa[searchCOSID];
        if(currstudent.COSID=-1){
            cout << "ID not asscoaited with a student";
        }else{
            cout << "The courses taken this semester by " << currstudent.fname  << " " << currstudent.lname << " include:";
            if(currstudent.totCourses > 0){
                for(int i=0; i<currstudent.totCourses;i++){
                cout << "\n" << currstudent.coursearr[i];
                }
            }
            else{cout << endl <<"No courses";}
        }



    while(Loopcheck == -1){
        cout << "\n\nEnter a couses (Q) to quit: ";
        cin >> LoopCOSID;
        if(LoopCOSID == "Q" || LoopCOSID=="q"){
            Loopcheck = 0;
        }else{
            string course;
            cout << endl << "Other students taking this course include: ";
            //printList(cout,FlexArray<Student>,searchCOSID,coursearr);
        }

    }
    return 0;


}

void printList (ostream& out,  FlexArray<Student> majors,  int cosID, string course){
    for (int i = 0; i<101; i++){

    }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:50:12+00:00Added an answer on May 26, 2026 at 2:50 pm
    For each student s in majors (silly name for a list of students isn't it?)
       if s.COSID is not cosID
           for each class c that s is taking
               if c equals course
                   display s.fname
    

    I think. It’s hard to tell. print other people in a paticular class when a course ID is inputed using this prototype: void printList (ostream& out, FlexArray<Student> majors, int cosID, string course); Does this mean print all the students who are taking course, except for that who’s COSID is the cosID parameter?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that takes data from an excel file and manipulates it
I have a perl program that takes input and output file arguments, and I'd
I have been assigned wit the task to write a program that takes a
I have a program, that takes a long time to load. Because of this,
I'm working on a program that takes a redirected file as input. For example,
I have a program that filters data and then outputs it to a tabg
Looking for help on writing a Perl program that takes an input file and
I have a [SQL 2008] SSIS package that takes a CSV text file and
I have a program that takes in stacks of TIFF images and is very
I am writing a program that takes in a CSV file and makes a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.