Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a Student structure that contains an integer variable id , a string variable name, and a float variable GPA. Write a program to read

Define a Student structure that contains an integer variable id, a string variable name, and a float variable GPA.
Write a program to read students' information from an input text file entered by the user. The program then print to the standard output
students' names who have a GPA>3.0 in order. For simplicity, you can safely assume that the number of students
in the file is always less than or equal to 10.
Ex: if the input file contains:
id=1234567 name=Peter GPA=3.6
id=1234568 name=Adina GPA=3.8
id=1234569 name=Mike GPA=3.0
id=1234569 name=Gina GPA=2.9
then the program will output
Peter
Adina
Note: the content in the input file may be empty.
You Must define and call the following function to read and parse the students' information from a text file. This function takes an ifstream
object (assuming the file is opened successfully), the Student array and an integer counting the number of students in the file as input.
void ReadStudentInfo(ifstream sifs, Student array[], int cnStudents);
Hint: use the getline () function to load the individual students' information one line at a time. To parse the information in this line, you
may use a stringstream object. Assume the student's information is stored in a string studentInfo, you then can create a
stringstream object as stringstream myStream (studentInfo). You then can use myStream>> to get the information like how
you used cins to get multiple input from the user. To suocessfully retrieve the individual information, you may need to first replace each
'=' with a whitespace ' before creating the stringstream object.
In the main () function,
first, create a Student array with 10 elements
second, read information into the created array, count the number of students in the file
third, print students names in the reversed order to the screen
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago