►Write a class implementation for a class Student that contains
the data members:

1. Data member for the student Name.

2. Data member for the student Number (ID).

3. Data member for the student Faculty.

4. Data member for the student Gender (M or F).

5. Data member for the student Average (GPA).

►The class should have the following member functions:

1. Default constructor to initialize all data members.

2. Parameterized constructor to initialize all data members.

3. Set functions to set the student name, number, faculty and gender.

4. Get functions for all data members.

5. Function Find_Average that sets the Average data member. This function asks the student to enter how many courses he has and his marks to set the Average data member.

6. Print function that prints the student name, number, faculty and average. This function should print if the student Pass or not.

► Write main function as follows:

1. Creates object std1, this object calls default constructor.

2. Creates object std2, this object calls parameterized constructor.

3. Call set functions for std1.

4. call Find_Average function for std1 and std2.

5. Print function for std1 and std2


plz any one help me ,,,

What have you done so far? Post your code, and put it within code tags, please.

i am so sorry ... i am not explain what i need .. but i need a solve for this program .. plz help me if u can

@ mzimmers
nothing (but it's just a guess).

Here's it but please from now on post your code example...

#include <iostream>									// I/O streams
#include <string>									// string facilities
#include <vector>
using namespace std;

class student										// class student
{
private:
	string name;									// student name
	int id;											// studen number(id)
	string faculty;									// student faculty
	char gender;									// gender (m for male, f for female)
	int average;									// student average number

public:
	// Default constructor
	student() : name("N/A"), id(0), faculty("N/A"), gender('0'), average(0){}

	//Parameterized constructor
	student(string n, int i, string f, char g, int a = 0) :
	name(n), id(i), faculty(f), gender(g), average(a){}

	//Set functions
	void set_name()
	{
		cout << "Enter student name: ";		cin >> name;
	}
	void set_id()
	{
		cout << "Enter student ID: ";		cin >> id;
	}
	void set_faculty()
	{
		cout << "Enter student faculty: ";	cin >> faculty;
	}
	void set_gender()
	{
		cout << "Enter student gender: ";	cin >> gender;
	}
	void set()
	{
		cout << "Enter student name: ";		cin >> name;
		cout << "Enter student ID: ";		cin >> id;
		cout << "Enter student faculty: ";	cin >> faculty;
		cout << "Enter student gender: ";	cin >> gender;
	}

	//Get functions	
	string get_name()
	{
		return name;
	}
	int get_id()
	{
		return id;
	}
	string get_faculty()
	{
		return faculty;
	}
	char get_gender()
	{
		return gender;
	}	

	//Find Average function
	void Find_Average();

	//Pirnt functions
	void print()
	{
		cout << "Student name: " << name << endl;
		cout << "Student ID: " << id << endl;
		cout << "Student faculty: " << faculty << endl;
		cout << "Student gender: (" << gender << ')' << endl;
		cout << "Student average: " << average << endl;
	}

};

//Find Average function
void student::Find_Average()
{
	int no_courses;																	// courses number
	int sum = 0;																	// for summing
	int degree[20];																// array for degrees in all courses
		
	cout << "Enter how many course did you have: "; cin >> no_courses;
		
	for(int i = 0; i < no_courses; i++)												// getting all degrees
	{
		cout << "Enter course number[" << i << "] degree: "; cin >> degree[i];
	}

	for(int i = 0; i < no_courses; i++)												// summing all degrees
	{
		sum += degree[i];
	}

	average = sum/no_courses;														// putting the average

}

int main()
{
	// default constructor object
	student std1;
	
	// parameterized constructors
	student std2("Ahmed", 1, "Computer Science", 'M');

	// std1 set functions
	std1.set_name();
	std1.set_id();
	std1.set_faculty();
	std1.set_gender();

	// get average for std1
	std1.Find_Average();
	
	// get average for std2
	std2.Find_Average();

	// print std1
	std1.print();

	// print std2
	std2.print();

	char ch; cin >> ch;
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.