Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- struct studentType
- {
- string firstName;
- string lastName;
- char courseGrade;
- int testScore;
- int programmingScore;
- double GPA;
- };
- void readIn(studentType& student);
- void printStudent(studentType& student);
- studentType setStudentCpy(studentType& student);
- int main()
- {
- studentType newStudent;
- studentType copyStudent;
- readIn(newStudent);
- printStudent(newStudent);
- copyStudent = setStudentCpy(newStudent);
- printStudent(copyStudent);
- return 0;
- }
- void readIn(studentType& student)
- {
- int score;
- cout << "Enter your first name: ";
- cin >> student.firstName;
- cout << "Enter your last name: ";
- cin >> student.lastName;
- cout << "Enter test score: ";
- cin >> student.testScore;
- cout << "Enter programming score: ";
- cin >> student.programmingScore;
- cout << "Enter your GPA: ";
- cin >> student.GPA;
- score = (student.testScore + student.programmingScore) / 2;
- if (score >= 90)
- student.courseGrade = 'A';
- else if (score >= 80)
- student.courseGrade = 'B';
- else if (score >= 70)
- student.courseGrade = 'C';
- else if (score >= 60)
- student.courseGrade = 'D';
- else
- student.courseGrade = 'F';
- }
- void printStudent(studentType& student)
- {
- cout << student.firstName << endl << student.lastName
- << endl << student.courseGrade << endl << student.testScore
- << endl << student.programmingScore << endl << student.GPA
- << endl;
- }
- studentType setStudentCpy(studentType& student)
- {
- return student;
- }
Add Comment
Please, Sign In to add comment