Answer to Question #158843 in C++ for Yeng

Question #158843

1.


Create a class named Student. A Student has fields for an ID number, number of credit hours earned, and number of points earned.

(For example, many schools compute grade point averages based on a scale of


4, so a three

-

credit

-

hour class in which a student earns an A is worth 12 points.)


a. Create 5 objects under Student class.


b. Include procedure to assign values to ID number, number of credit hours of each student. Also an input f or the standard scale


c. Display Students ID and number of credit hours with the computed points earned.


d. Compute for an average points earned of the student



1
Expert's answer
2021-01-27T06:40:52-0500
#include <iostream>
#include <string>
//**************************************************
using namespace std;
//**************************************************
class Student
{
public:
	string ID;
	int CreditHours;
	int PointsEarned;
	void Display();
	double Average();
};


void Student::Display()
{
	cout << "Student ID: " <<ID << ": number of creadits hours earned: " << CreditHours << ": number of points earned: " << PointsEarned
		<< ": average points earned of strudent: " << this->Average() << endl;
}


double Student::Average()
{
	return (double)PointsEarned/CreditHours;
}
//**************************************************
int main()
{
	Student S[5];
	for(int i = 0; i < 5; i++)
	{
		cout << "Enter ID of " << i+1 << " student: ";
		cin >> S[i].ID;
		cout << "Enter his number of creadits hours: ";
		cin >> S[i].CreditHours;
		cout << "Enter his number of points earned: ";
		cin >> S[i].PointsEarned;
		cout << "*************************************************" << endl;
	}
	cout << "Display Informatio!" << endl;
	cout << "*************************************************" << endl;
	for(int i = 0; i < 5; i++)
	{
		S[i].Display();
	}
	cout << "Enter any value to continue: ";
	string msg;
	cin >> msg;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog