This is what is in the text file: 1: Maude Flanders, 272754: 1.72: Alice Glick, 459608: 1.93:
Fantastic news! We've Found the answer you've been seeking!
Question:
This is what is in the text file:
1: Maude Flanders, 272754: 1.72: Alice Glick, 459608: 1.93: Sarah Wiggum, 920562: 24: Luann Van Houten, 737447: 2.35: Apu Nahasapeemapetilon, 290816: 2.66: Surly Duff, 146127: 2.67: Homer Simpson, 413084: 2.98: Allison Taylor, 747954: 3.29: Martin Prince, 575687: 3.5
Transcribed Image Text:
Write a C++ program that reads the data from a file (students.txt), stores it in the heap memory and then displays on the console. You are required to perform the following tasks: A. Create a Student class with the following data members: • string id • string name • double gpa Make sure to have all the appropriate getters and setters along with a void toString() method that can display all the student information in the form shown in the expected output screenshot. B. Your program should have at least the following global functions (outside class and main method) to extract the information from each line of the file: • string extractID(string str) to extract the student id • string extractName(string str) to extract the student name • double extractGPA(string str) to extract the gpa in double C. Your program should read each line from the file, extract student id, name and gpa using the above functions and then create a Student object of the class Student and finally stores that student object in an array of students objects inside the heap. D. You might want to create a resize function Student* resize(Student* arr, int* size) to resize the student array in the heap on every read of a line from the file. E. You might also want to create a display function void display(Student* arr, int size) to display all the information by calling toString() method of student class for all the objects in the student array. F. You are allowed to use only #include<iostream> #include<fstream> and #include<string>. Below is the expected output of the program: Microsoft Visual Studio Debug Console Student ID: 272754, Name: Maude Flanders, GPA: 1.7 Student ID: 459688, Name: Alice Glick, GPA: 1.9 Student ID: 920562, Name: Sarah Wiggum, GPA: 2 Student ID: 737447, Name: Luann Van Houten, GPA: 2.3 Nahasapeenapetilon, GPA: 2.6 Student ID: 298816, Name: Student ID: 146127, Name: Surly Duff, GPA: 2.6 Student ID: 413884, Name: Homer Simpson, GPA: 2.9 Student ID: 747954, Name: Allison Taylor, GPA: 3.2 Student ID: 575687, Name: Martin Prince, GPA: 3.5 Write a C++ program that reads the data from a file (students.txt), stores it in the heap memory and then displays on the console. You are required to perform the following tasks: A. Create a Student class with the following data members: • string id • string name • double gpa Make sure to have all the appropriate getters and setters along with a void toString() method that can display all the student information in the form shown in the expected output screenshot. B. Your program should have at least the following global functions (outside class and main method) to extract the information from each line of the file: • string extractID(string str) to extract the student id • string extractName(string str) to extract the student name • double extractGPA(string str) to extract the gpa in double C. Your program should read each line from the file, extract student id, name and gpa using the above functions and then create a Student object of the class Student and finally stores that student object in an array of students objects inside the heap. D. You might want to create a resize function Student* resize(Student* arr, int* size) to resize the student array in the heap on every read of a line from the file. E. You might also want to create a display function void display(Student* arr, int size) to display all the information by calling toString() method of student class for all the objects in the student array. F. You are allowed to use only #include<iostream> #include<fstream> and #include<string>. Below is the expected output of the program: Microsoft Visual Studio Debug Console Student ID: 272754, Name: Maude Flanders, GPA: 1.7 Student ID: 459688, Name: Alice Glick, GPA: 1.9 Student ID: 920562, Name: Sarah Wiggum, GPA: 2 Student ID: 737447, Name: Luann Van Houten, GPA: 2.3 Nahasapeenapetilon, GPA: 2.6 Student ID: 298816, Name: Student ID: 146127, Name: Surly Duff, GPA: 2.6 Student ID: 413884, Name: Homer Simpson, GPA: 2.9 Student ID: 747954, Name: Allison Taylor, GPA: 3.2 Student ID: 575687, Name: Martin Prince, GPA: 3.5
Expert Answer:
Answer rating: 100% (QA)
Here is a possible implementation of the program Here is a solution in C include include include include using namespace std class Student private str... View the full answer
Related Book For
Fundamentals of biochemistry Life at the Molecular Level
ISBN: 978-0470547847
4th edition
Authors: Donald Voet, Judith G. Voet, Charlotte W. Pratt
Posted Date:
Students also viewed these programming questions
-
A crane boom of mass 450 kg with its center of mass at C is stabilized by two cables AQ and BQ (Ae = 304 mm2 for each cable) as shown in the figure. A load P = 20 kN is supported at point D. The...
-
What statement(s) in the text suggests that native protein structure is highly labile?
-
Here is what occurs in the following scenario: Bill has an income of $50,000 and has a probability of remaining healthy of 70%. If he is not healthy, Bill has the following projected medical costs...
-
Farley, Inc., is a manufacturer that produces customized computer components for several wellknown computer-assembly companies. Farleys latest contract with CompWest.com calls for Farley to deliver...
-
A friend of yours is trying to value the equity of a company and, knowing that you have read this book, has asked for your help. So far she has tried to use the FCFE approach. She estimated the cash...
-
Two manned satellites approach one another at a relative speed of 0.190 m/s, intending to dock. The first has a mass of 4.70 10 3 kg, and the second a mass of 7.90 10 3 kg. If the two satellites...
-
The triangular blocks are glued along each side of the joint. A C-clamp placed between two of the blocks is used to draw the joint tight. If the clamping force is F = 900N, determine the average...
-
In 2010, Carver Electronics Co. began selling a new computer that carried a 2-year warranty against defects. Based on the manufacturer's recommendations, Carver projects estimated warranty costs (as...
-
Suppose a chair manufacture has the following costs and sales expectations: Total variable costs: $ 1 , 0 0 0 , 0 0 0 Total fixed costs: $ 4 0 0 , 0 0 0 Expected unit sales: 2 0 , 0 0 0 1 . With...
-
Freddy, Inc. had outstanding 10 percent, $1,000,000 face value, convertible bonds maturing on December 31, 2017. Interest is paid December 31 and June 30. After amortization through June 30, 2014,...
-
A cube of ice of density 0.92 floats in a container of water. If the cube has a volume of 1000 cm, what is the volume of the cube that will cm be below the surface of the water?
-
How does the organizational culture contribute to or hinder organizational learning, knowledge sharing, and continuous improvement initiatives?
-
A uniform horizontal lever of length 2.4 m is pivoted at its mid-point. The following forces are acting on the lever: a 6 N upward force (force with upward vertical component) that makes an angle of...
-
Exercise 2-2 Incoterm Scenario Pasquale works in the shipping department for Forno Bravo Pizza Ovens located in Venice, Italy. He has a wholesaler that is purchasing two containers loaded with pizza...
-
A typical muscle fiber is 2 . 0 2 . 0 cm long and has a cross - section area of 3 . 1 3 . 1 times 1 0^ 9 1 0 9 m . Unknown node type: sup . When the muscle fiber is stimulated, it pulls with a force...
-
The legislature in a state has 57 seats. Apportion these seats to the five counties below using Jefferson's method. County Population Seats Received Adams 358,000 Grant 261,000 Colton 286,000 Davis...
-
Refer to the data in QS 10-1. Based on financial considerations alone, should Helix accept this order at the special price? Explain.
-
Aldolase catalyzes the reaction ÎG°² for this reaction is 22.8 kJmol-1. In the cell at 37°C, the ÎG for this reaction is -5.9 kJmol-1. What is the ratio [GAP][DHAP]/[FBP]?...
-
You have discovered a novel eukaryotic RNA polymerase. To study this enzyme, you have developed an in vitro assay with an inhibitor of RNA chain elongation, 3-deoxy-5[-32P] CTP. You are surprised by...
-
(a) Describe how glycerol enters the glycolytic pathway. (b) What is the ATP yield for the conversion of glycerol to pyruvate?
-
Using the data in exercise 2, determine how many units of resources the firm will want to acquire. Data from in exercise 2 Using the information in the following table, calculate the marginal revenue...
-
What does it mean to say that the demand for resources is a derived demand? Is the demand for all goods and services a derived demand?
-
Using the information in the following table, calculate the marginal revenue product (MRP = MPP MR). Unit of Resources Total Resource Output Price Price 1 10 $5 $10 2 25 $5 $10 345 35 $5 $10 40 $5...
Study smarter with the SolutionInn App