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 inputoutput creating a struct, passing a struct to a function, saving data to and reading from a struct. Be sure to read this lab thoroughly, especially the Handin 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
b Prompt the user for a last name and read the last name into the instance of s tudentTYpe from
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 or 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 student to:
a Assign a letter grade to the student in the letterGrade field. If the student's grade is:
i give a
ii give a D
iii. give a C
iv give a
v give a
Uses a user defined function printstudentDa ta studentType student to:
a Print the data from the instance of studentType from
main should only contain variable declarations and function calls to your userdefined 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 for this lab. Sec the example output for examples and formatting.
Prototypes for your user defined functions are:
void getstudentData studentTyped;
void getLetterGrade studentType :
void printstudentData studentType;
components and not needed in your program:
Example
AlexsMac:laba slex gtMall pedantio Warror maln. Opp
AlexsMad:laba slex a out
Enter a liret neme
tiJohn
Enter a last name
th min th
Enter a grade
thereox
Exrox: Invalld grade
Enter a grade
Exrox: Invalld grade
Enter a grade
Invalld
Exrox: Invalld grade
Enter a grade
Exrox: Invalld grade
Enter a grade
x
Exrox: Invalld grade
Enter a grade
Errox: Invelld grade
Enter a grade
Error: Invalid grade
Enter a grade
w
Data Entered
student, first:Name John
student, lastName Smith
student.grade
a tudent. letterGrade
Enter a Ilrot name
Encer a late neme
ntes tonieData Enteredstudent. Arstriame Pebbiesetudent. Instriame Flintsoneatudent, grade etudent. lettergrade A
Example
Enter a flret name
Enter la lat name
t s Sherman
Enter a grade
Data Entered
atudent. IIrstilame
atudent. Iastwame Sherman
student.grade
student, letterGrade B
Example
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
