Question
C++: Consider the following code segment: enum GradeLevel { FRESHMAN , SOPHMORE , JUNIOR , SENIOR }; struct Student { string first ; string middle
C++: Consider the following code segment:
enum GradeLevel { FRESHMAN, SOPHMORE, JUNIOR, SENIOR };
struct Student
{
string first;
string middle;
string last;
GradeLevel year;
float GPA;
};
Student A0012; // Student ID A0012
Student A0013; // Student ID A0013
A0012.first = "Bjarne";
A0012.last = "Stroustrup";
A0012.GPA = 3.56;
A0013 = A0012;
A0012.year = SENIOR;
A0013.middle = "C++";
A0013.year = static_castGradeLevels>(A0012.year - 2);
A0013.GPA = floor(A0012.GPA); // floor() rounds down to whole number
A0012.middle = A0013.middle.at(0) + ".";
What are the contents of the Student variables after this code has executed? Use the chart provided. Who is Bjarne Stroustrup anyway (Google it)?
Field | A0012 | A0013 |
string first |
|
|
string middle |
|
|
string last |
|
|
GradeLevel year |
|
|
float GPA |
|
|
10. (8 Points) Consider the following code segment: enum GradeLevel \{ FRESHMAN, SOPHMORE, JUNIOR, SENIOR \}; struct Student \{ string first; string middle; string last; GradeLevel year; float GPA; \}; Student A0012; // Student ID A0012 Student A0013; // Student ID A0013 A0012.first = "Bjarne" A0012.last = "Stroustrup"; A0013=A0012; AO012, year = SENIOR; A0013. middle =nC++; A0013. year = static_cast>( A0012. year 2); A0013.GPA = floor (A0012.GPA); // floor () rounds down to whole number A0012 middle = A0013.middle at (0)+nn; What are the contents of the Student variables after this code has executed? Use the chart provided. Who is Bjarne Stroustrup anyway (Google it)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started