C
corpuszero
i'm having problems with my hw assignment, i've been trying for so many days
and still haven't found a way to code according to the instructor's
checklist
----------------------------------------------------------------------------
----------------------------------------------
enum
Use the follow for this problem:
enum status{freshman, sophomore, junior, senior};
struct student
{
char name[20];
status year;
int major;
long ssn;
float gpa;
};
in your program create a structure variable of the above type and initialize
it at the time the variable is create. then change the status and gpa of the
structure variable by using the assignment operator. Make sure to display
the contents of all 5 data members before and after the changes are make.
checklist:
1. there is no input in this problem, only initialization and assignment
using the assignment operator.
2. initialization means placing value(s) into a variable at the time the
variable is create.
3. right after initialization display the contents of the entire variable.
that means the value for name, year, major, ssn, and gpa with proper labels.
4. then assign values to the year and gpa data members of the structure
variable.
5. right after the assignment display the contents of the entire variable
with proper labels.
6. use const char* const statusDesc[ ] = {"freshman", "sophomore", "junior",
"senior"} to translate the year from a number to a word.
7. to display the contents of the structure variable use a separate
function. As a result steps 3 and 5 are performed by calling the display
function.
----------------------------------------------------------------------------
----------------------------------------------
Here's what i have:
#include<iostream>
using namespace std;
enum status{freshman, sophomore, junior, senior};
struct student
{
char name[20];
status year;
int major;
long ssn;
float gpa;
};
int main()
{
student doan = {"Doan", sophomore, 13, 123456789, 3.5};
cout<<"Name: "<<doan.name<<endl
<<"Year: "<<doan.year<<endl
<<"Major: "<<doan.major<<endl
<<"SSN#: "<<doan.ssn<<endl
<<"GPA: "<<doan.gpa<<endl<<endl;
const char *const statusDesc[]={"freshman", "sophomore", "junior",
"senior"};
cout<<"Name: "<<doan.name<<endl
<<"Year: "<<doan.year<<endl
<<"Major: "<<doan.major<<endl
<<"SSN#: "<<doan.ssn<<endl
<<"GPA: "<<doan.gpa<<endl<<endl;
return 0;
}
and still haven't found a way to code according to the instructor's
checklist
----------------------------------------------------------------------------
----------------------------------------------
enum
Use the follow for this problem:
enum status{freshman, sophomore, junior, senior};
struct student
{
char name[20];
status year;
int major;
long ssn;
float gpa;
};
in your program create a structure variable of the above type and initialize
it at the time the variable is create. then change the status and gpa of the
structure variable by using the assignment operator. Make sure to display
the contents of all 5 data members before and after the changes are make.
checklist:
1. there is no input in this problem, only initialization and assignment
using the assignment operator.
2. initialization means placing value(s) into a variable at the time the
variable is create.
3. right after initialization display the contents of the entire variable.
that means the value for name, year, major, ssn, and gpa with proper labels.
4. then assign values to the year and gpa data members of the structure
variable.
5. right after the assignment display the contents of the entire variable
with proper labels.
6. use const char* const statusDesc[ ] = {"freshman", "sophomore", "junior",
"senior"} to translate the year from a number to a word.
7. to display the contents of the structure variable use a separate
function. As a result steps 3 and 5 are performed by calling the display
function.
----------------------------------------------------------------------------
----------------------------------------------
Here's what i have:
#include<iostream>
using namespace std;
enum status{freshman, sophomore, junior, senior};
struct student
{
char name[20];
status year;
int major;
long ssn;
float gpa;
};
int main()
{
student doan = {"Doan", sophomore, 13, 123456789, 3.5};
cout<<"Name: "<<doan.name<<endl
<<"Year: "<<doan.year<<endl
<<"Major: "<<doan.major<<endl
<<"SSN#: "<<doan.ssn<<endl
<<"GPA: "<<doan.gpa<<endl<<endl;
const char *const statusDesc[]={"freshman", "sophomore", "junior",
"senior"};
cout<<"Name: "<<doan.name<<endl
<<"Year: "<<doan.year<<endl
<<"Major: "<<doan.major<<endl
<<"SSN#: "<<doan.ssn<<endl
<<"GPA: "<<doan.gpa<<endl<<endl;
return 0;
}