Question: INSTRUCTIONS: 1. read a text file containing student information and their grade for the current semester 2. and check whether they are failing all courses

INSTRUCTIONS:

1. read a text file containing student information and their grade for the current semester

2. and check whether they are failing all courses (3 total).

==== structs ====

1. You are to declare 3 structures called

a) Name

b) Grades

c) StudentInfo

2. The structure Name contains two char arrays containing a students

a) first and

b) last name.

3. The structure Grades contains 3 chars that hold the grades for three classes the student is taking:

a) math

b) science

c) English

4. The last structure StudentInfo contains 3 datatypes:

a) an int for student ID

b) a Name

c) and Grades.

5. The structure StudentInfo will hold all the information needed for the student.

6. In main, youre to create an array of the structure StudentInfo that can hold as many students as there are in the file StudentInfo.txt.

6a. Youll open the file in main (be sure to check if it is opened!)

7. and call the function ReadFile to read the contents of the file and store them appropriately in the structure array before returning to main.

8. Once the student info is read and stored, main will call the function IsFailing and check which students are failing all the classes.

9. Mains job is to simply open the file, call the ReadFile and IsFailing functions.

// ==== ReadFile ==============================================================

// Note: this function returns nothing.

// ============================================================================

1. ReadFile will take as argument

a) the file to read

b) the StudentInfo structure array

c) and the number of students.

2. It will store all the information from the text file into the structure.

// ==== IsFailing =============================================================

// Note: this function returns nothing.

// ============================================================================

1. IsFailing will take as argument

a) the StudentInfo structure array

b) and the number of students.

2. It will check each student who is failing all three courses.

3. --IF--- a student is failing all three courses

a) it will call DispName to display the name of the student who is failing.

4. -- IF -- there are no students who are failing

a) then a message will be printed to the output screen that no students are currently failing.

// ==== DispName ==============================================================

1. will take as argument a StudentInfo structure and display the first and last name to the output screen.

Given this file StudentInfo.txt:

First Last ID# Math Science English

Kathi Egan 55390330 D D C

Olive Popp 74709392 C F C

Danielle Calender 63690967 B C F

Renato Mumaw 54699973 D A D

Art Loud 29121801 B B B

Maxima Turner 76930478 B B A

Sheilah Nitta 87678926 B C C

Ellena Primus 49547452 D A D

Bethany Monson 16236039 C D B

Mariko Redfield 39821410 D B C

Sina Schram 61171256 F F F

Juliet Zane 72420173 B C A

Contessa Munsey 28740060 B B F

Gaston Gladson 23868818 B F C

Kelly Fitzhugh 93401136 B F A

Loren Laxson 64894156 A B A

Melodie Fleet 30602626 D B D

Wesley Fontanez 35341613 F F F

Essie Helland 75933521 A A A

Elinore Dennard 81757423 A D D

Lolita Creamer 52056649 D D D

Eugenio Kopp 61978510 C B A

Lorrie Wittig 96803653 A A A

Nenita Holub 69213190 C C B

Werner Brocious 77268285 D B D

Heriberto Hassinger 71824977 D B B

Cherise Folts 58267344 F A C

Julie Wunsch 59240552 B D F

Syreeta Silverstein 97547610 F F F

Romelia Sill 39975652 C C F

== test runs ==

A sample run is as follows:

The following student(s) are failing:

Sina Schram

Wesley Fontanez

Syreeta Silverstein

Another sample run is as follows:

The following student(s) are failing:

No students are failing!

Here is my code, it displays ASCII values when I am just trying to display text from the file so i havent begun IsFailing function:

#include

#include

#include

#include

using namespace std;

// Constants

const int CLASS_SIZE = 30;

// Structures

struct Name

{

//

char firstName[64];

char lastName[64];

};

struct Grades

{

//

char mathGrade[64];

char sciGrade[64];

char englGrade[64];

};

struct StudentInfo

{

//

Name studentName;

int studentId;

Grades studentGrade;

};

// Function Prototypes

void ReadFile(ifstream& inFile, StudentInfo students[], const int CLASS_SIZE);

// StudentInfo IsFailing(StudentInfo sArray[], int CLASS_SIZE);

void DispName(StudentInfo students[], const int CLASS_SIZE);

// ==== main ==================================================================

//

// ============================================================================

int main()

{

ifstream inFile;

// 30 instances of StudentInfo

StudentInfo students[CLASS_SIZE];

// Open StudentInfo.txt

inFile.open("StudentInfo.txt");

// Check if file is open before calling other functions

if (!inFile.is_open())

{

cout << "There was a problem opening your file." << endl;

exit(1);

}

cout << "reading the file..." << endl;

ReadFile(inFile, students, CLASS_SIZE);

// Close StudentInfo.txt

inFile.close();

// Display file output

DispName(students, CLASS_SIZE);

return 0;

}

// ==== ReadFile ==============================================================

void ReadFile(ifstream& inFile, StudentInfo students[], const int CLASS_SIZE)

{

int index;

// read inFile into StudentInfo struct -

for (index = 0; index < CLASS_SIZE; ++index)

{

inFile >> students[index].studentName.firstName

>> students[index].studentName.lastName

>> students[index].studentId

>> students[index].studentGrade.mathGrade

>> students[index].studentGrade.sciGrade

>> students[index].studentGrade.englGrade;

}

} // end of "ReadFile"

// ==== IsFailing =============================================================

// StudentInfo IsFailing([], const int CLASS_SIZE)

// {

// } // end of "IsFailing"

// ==== DispName ==============================================================

void DispName(StudentInfo students[], const int CLASS_SIZE)

{

int index;

// read inFile into StudentInfo struct -

for (index = 0; index < CLASS_SIZE; ++index)

{

cout << students[index].studentName.firstName << " "

<< students[index].studentName.lastName << " "

<< students[index].studentId << " "

<< students[index].studentGrade.mathGrade << " "

<< students[index].studentGrade.sciGrade << " "

<< students[index].studentGrade.englGrade << " "

<< " ";

}

} // end of "DispName"

update/edit:

updated this

struct StudentInfo

{

//

Name studentName[128];

int studentId;

Grades studentGrade[256];

};

and now receive an error telling me to include size type... i think i could be in the right direction but not sure how to use int for the ID this way.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!