Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Name of file must be problem1.cpp CPP State College has a student file with the following data: (students.dat) Social Security No. - Student Name -

Name of file must be problem1.cpp
image text in transcribed
image text in transcribed
CPP State College has a student file with the following data: (students.dat) Social Security No. - Student Name - Class Code - School Code GPA -Credits Earned Class Codes: 1Freshman 3Junior 4 Senior School Codes: 1Business 2 Liberal Arts Write a program that will read student data from file and print summary data as follows a. The percentage of students with a GPA of 1. less than 2.0 2. between 2.0 and 3.0 (inclusive) 3. greater than 3.0 b. The percentage of students with GPAs greater than 3.0 who are: Business majors 2. 1. LUberal Arts majors Engineering majors 3. The percentage of students who have earned more than 100 credi ts and have GPAs less than 2.00 The percentage of students with GPAs greater than 3.0 who are: C. d. . Freshmen 2. Sophomores 3. Juniors 4. Seniors Coding requirements/options: Read from the file into an array of structs Use enumerators in your code, example: enun (FRESHI AN . 1, SOPHORE-2, Reading from file options: 1. 2. JUNIOR . 3, SENIOR-4); 3. Define a maximum number of lines and define an array of structs accordingly (inefficient). a. Count number of lines in file then dynamically allocate memory for the array of structs. Check how these functions are used to count number of lines in file fin.unsetf(ios base::skipws) /I count the newlines with an algoritha specialized for counting: unsigned line_count count (istrean iteratorcchar (fin) istrean iteratorcchar> n) //position streaming pointer back to the beginning of file b. count the nowlines cstto(n) fin.seekg (e, ios::beg); fin>>skipws; //white space skipping flag -default c. Read from the file into a vector (most efficient solution). You need to read from the file to a temporary struct variable first, then push back this temporary variable into the vector

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

Students also viewed these Databases questions