Question: Write a program that will do the following: Create a structure definition with the tag studentInfo for a struct that will store the following data:
Write a program that will do the following:
Create a structure definition with the tag studentInfo for a struct that will store the following data:
Name: Ann Annson
(char array, up to 100 characters, including the null terminator)
Age: 10
GPA: 1.10
Grade: D
Create an array of students of 4 of these and initialize with the following data:
Ann Annson, 10, 1.10, D Bill Billson, 20, 2.20, C Carl Carlson, 30, 3.30, B Don Donson, 40, 4.00, A
Using text mode I/O, write the data in the array to a file called students.txt
You should wirte out the data in the following format:
age + + gpa + + grade + + name +
Using binary mode I/O, write the data in the array to a file called students.bin
Create two new arrays of studentInfo
Call the first studentsText and the second studentsBinary
Each should have 50 elements
Read the data from newStudents.txt into studentsText
Data will be in the same format as you are supposed to print out.
Read the data form newStudents.bin into studentsBinary
Display the data from the array studentsText on the screen
Display the data from the array studentsBinary on the screen
Call a function called randomRead
Random Read:
Declare a new studentInfo variable called temp
Prompt the user for the student number to read
If the requested record is out of range (below 1 or above the number of records), inform the user that no record exists.
Loop until the user provides valid input
Using random access commands, read just that record from the newStudents.bin file, into temp
Display the contents of temp on the screen
NOTE: Do not use the string class in your struct definition. Use the old c-style string (i.e. array of char)
NOTE: Use a precision of 3 digits for printing the GPA
To help with debugging, the provided files for newStudents.bin and newStudents.txt both contain which file the student came from, as well as which index the student was as part of their name and age.
About the data:
The names are generated names; they do not correspond to anyone.
The age is literally which index in the array they were when I created the files
The GPA is generated from a random number generator, with a range of 0.0 to 4.0. This range does not represent an actual grade distribution.
The Grade is based on the GPA, using a simple system of the floor(GPA)
Sample Output:
Data read from "newStudents.txt"
TXT - Talisha Triplett 1 2.271 C
TXT - Hanna Hoyos 2 2.136 C
TXT - Cira Corrie 3 3.730 B
TXT - Yer Yan 4 1.956 D
TXT - Sarina Such 5 3.997 B
TXT - Herman Higley 6 0.723 F
TXT - Tiffaney Theobald 7 2.435 C
TXT - Stuart Sedberry 8 3.628 B
TXT - Antoine Anders 9 0.693 F
TXT - Hilaria Heilig 10 2.911 C
TXT - Jess Jenner 11 0.828 F
TXT - Jacqulyn Jessop 12 1.604 D
TXT - Hugh Hyneman 13 3.198 B
TXT - Hanh Hallford 14 1.772 D
TXT - Alisa Allman 15 3.778 B
TXT - Jenifer Jager 16 0.817 F
TXT - Maris Mccarville 17 0.799 F
TXT - Magaly Merideth 18 0.817 F
TXT - Tamela Thome 19 0.700 F
TXT - Mitzi Moreman 20 3.849 B
TXT - Rebbecca Rubino 21 0.871 F
TXT - Ilene Iddings 22 1.874 D
TXT - Patrina Polen 23 2.956 C
TXT - Marcy Maines 24 0.151 F
TXT - Amberly Archey 25 0.542 F
TXT - Eladia Erb 26 3.015 B
TXT - Julio Jahn 27 3.712 B
TXT - Consuela Cullinan 28 0.005 F
TXT - Katelyn Knighten 29 1.531 D
TXT - Thelma Twiggs 30 3.163 B
TXT - Milissa Montes 31 3.748 B
TXT - Retha Ruel 32 2.522 C
TXT - Sonny Stellhorn 33 3.479 B
TXT - Tammie Thames 34 2.259 C
TXT - Anastacia Avey 35 3.194 B
TXT - Genevive Gillman 36 1.506 D
TXT - Marquetta Meldrum 37 3.521 B
TXT - Deneen Dempsey 38 1.168 D
TXT - Quentin Quinton 39 0.077 F
TXT - Jeana Justin 40 1.710 D
TXT - Kayleigh Koening 41 3.156 B
TXT - Mckinley Mcguckin 42 0.502 F
TXT - Elenora Egnor 43 1.026 D
TXT - Britta Bosch 44 0.859 F
TXT - Miranda Mciver 45 2.279 C
TXT - Luetta Lough 46 2.061 C
TXT - Kym Klassen 47 3.183 B
TXT - Monroe Mcmurtry 48 1.495 D
TXT - Nga Needham 49 3.587 B
TXT - Myung Malave 50 0.711 F
Data read from "newStudents.bin"
BIN - Talisha Triplett 1 2.271 C
BIN - Hanna Hoyos 2 2.136 C
BIN - Cira Corrie 3 3.730 B
BIN - Yer Yan 4 1.956 D
BIN - Sarina Such 5 3.997 B
BIN - Herman Higley 6 0.723 F
BIN - Tiffaney Theobald 7 2.435 C
BIN - Stuart Sedberry 8 3.628 B
BIN - Antoine Anders 9 0.693 F
BIN - Hilaria Heilig 10 2.911 C
BIN - Jess Jenner 11 0.828 F
BIN - Jacqulyn Jessop 12 1.604 D
BIN - Hugh Hyneman 13 3.198 B
BIN - Hanh Hallford 14 1.772 D
BIN - Alisa Allman 15 3.778 B
BIN - Jenifer Jager 16 0.817 F
BIN - Maris Mccarville 17 0.799 F
BIN - Magaly Merideth 18 0.817 F
BIN - Tamela Thome 19 0.700 F
BIN - Mitzi Moreman 20 3.849 B
BIN - Rebbecca Rubino 21 0.871 F
BIN - Ilene Iddings 22 1.874 D
BIN - Patrina Polen 23 2.956 C
BIN - Marcy Maines 24 0.151 F
BIN - Amberly Archey 25 0.542 F
BIN - Eladia Erb 26 3.015 B
BIN - Julio Jahn 27 3.712 B
BIN - Consuela Cullinan 28 0.005 F
BIN - Katelyn Knighten 29 1.531 D
BIN - Thelma Twiggs 30 3.163 B
BIN - Milissa Montes 31 3.748 B
BIN - Retha Ruel 32 2.522 C
BIN - Sonny Stellhorn 33 3.479 B
BIN - Tammie Thames 34 2.259 C
BIN - Anastacia Avey 35 3.194 B
BIN - Genevive Gillman 36 1.506 D
BIN - Marquetta Meldrum 37 3.521 B
BIN - Deneen Dempsey 38 1.168 D
BIN - Quentin Quinton 39 0.077 F
BIN - Jeana Justin 40 1.710 D
BIN - Kayleigh Koening 41 3.156 B
BIN - Mckinley Mcguckin 42 0.502 F
BIN - Elenora Egnor 43 1.026 D
BIN - Britta Bosch 44 0.859 F
BIN - Miranda Mciver 45 2.279 C
BIN - Luetta Lough 46 2.061 C
BIN - Kym Klassen 47 3.183 B
BIN - Monroe Mcmurtry 48 1.495 D
BIN - Nga Needham 49 3.587 B
BIN - Myung Malave 50 0.711 F
Enter a student number to read (1-50): 21
Student #21: "BIN - Rebbecca Rubino" 21 0.871 F
Press any key to continue . . .
******PLEASE DO THIS PROBELM IN C++****DO NOT USE "CONIO"********
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
