Question: In this lab you will practice using basic input / output , creating a C + struct, passing a struct to a function, saving data

In this lab you will practice using basic input/output, creating a C+ struct, passing a struct to a function, saving data to and reading from a struct. Be sure to read this lab thoroughly, especially the Hand-in Procedure
Lab
To start your lab you will need a struct to read data into. The struct definition should be placed above main () and below using namespace std. The struct should be called studentType and contain the following members:
string firstName
string lastName
int grade
char letterGrade
Now that we have the needed struct, write a complete program that:
Creates an instance of the s tudentrype struct.
Uses a user defincd function getStuden tData (studentType student) to:
a. Prompt the user for a first name and read the first name into the instance of s tudentType from (1).
b. Prompt the user for a last name and read the last name into the instance of s tudentTYpe from (1).
c. Prompt the user for a grade and read the grade into the instance of s tudentType from (I). If an integer is not entered or a number 0 or >4 is eritered the stream should be cleared, any previous values read should be discarded, and the user prompted again until a valid number is input.
Uses a user defined function getLettergrade (studentType s student) to:
a. Assign a letter grade to the student in the letterGrade field. If the student's grade is:
i.0 give a 'F'
ii.1 give a 'D'
iii. 2 give a 'C'
iv.3 give a 'B'
v.4 give a ?'A
Uses a user defined function printstudentDa ta (studentType student) to:
a. Print the data from the instance of studentType from (1)(2).
main () should only contain variable declarations and function calls (to your user-defined functions). All data must be read into a struct first, then the required grade foundloutput. You must write all of the functions in this lab, failing to do so will result in you receiving a 0 for this lab. Sec the example output for examples and formatting.
Prototypes for your user defined functions are:
void getstudentData (studentTyped);
void getLetterGrade (studentType 6) :
void printstudentData (studentType);
components and not needed in your program):
Example 1
Alexs-1Mac:lab10a slex gt+-Mall -pedantio -Warror maln. Opp
Alexs-1Mad:lab10a slex ./a out
Enter a liret neme
tiJohn
Enter a last name
th 5 min th
Enter a grade
thereox
Exrox: Invalld grade
Enter a grade
*41.1.1
Exrox: Invalld grade
Enter a grade
Invalld
Exrox: Invalld grade
Enter a grade
x+235
Exrox: Invalld grade
Enter a grade
*x-1
Exrox: Invalld grade
Enter a grade
****247
Errox: Invelld grade
Enter a grade
+5
Error: Invalid grade
Enter a grade
w.4
Data Entered
student, first:Name = John
student, lastName = Smith
student.grade =4
a tudent. letterGrade =A
Enter a Ilrot name
Encer a late neme
*114ntes tonieData Enteredstudent. Arstriame = Pebbiesetudent. Instriame = Flintsoneatudent, grade =4etudent. lettergrade =A
Example 3
Enter a flret name
****P.
Enter la lat name
t s Sherman
Enter a grade
+3
Data Entered
,atudent. IIrstilame =P.
,atudent. Iastwame = Sherman
,student.grade =3
,student, letterGrade = B
Example 4
In this lab you will practice using basic input /

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 Programming Questions!