Question

A class allows a group of one or more member objects to have a series of...

A class allows a group of one or more member objects to have a series of common characteristics and functions.

Create a class (student) that contains the member characteristics:

Student ID (string)

Student Last Name (string)

Student First Name (string)

GPA (float)

Number of enrolled classes (integer)

The class functions are:

setID (string passed to function to set Student ID)

setLastName (string passed to function to set Student Last Name)

setFirstName (string passed to function to set Student First Name)

setGPA (float passed to function to set GPA)

setClasses (integer passed to function to set Number of enrolled classes)

DisplayStudent (display member fields’ values from within this function)

SetALL (strings, float and integer passed to function setting the appropriate field)

Application will:

Create four class members (student1, student2, student3, student4)

Initialize the class members with the SetALL function

Display each member’s individual characteristics

Allow user to enter a NEW class member, student5 or student6)

Allow user to run this repeatedly (some sort of menu presentation??)

Output Example - Displaying the students' data:

Student ID: AF101

Smith, Zachery H.

4 Classes Taken This Semester

Current GPA is 3.2

Student ID: HJ389

Jones, Alias T.

2 Classes Taken This Semester

Current GPA is 3.3

Student ID: KL209

Luzer, Emma P.

4 Classes Taken This Semester

Current GPA is 4

Student ID: LL309

Beans, Hill O.

3 Classes Taken This Semester

Current GPA is 2.5

Hit Any Key to continue...

0 0
Add a comment Improve this question Transcribed image text
Answer #1

c++ code:

#include <iostream>

using namespace std;

//student class
class Student
{
//member variables
string ID;
string LastName;
string FirstName;
float GPA;
int classes;

//functions
public:
//setters
void setID (string id){
this->ID =id;
}
void setLastName (string lname)
{
this->LastName=lname;
}
void setFirstName (string fname)
{
this->FirstName=fname;
}
void setGPA (float gpa)
{
this->GPA=gpa;
}
void setClasses (int classes)
{
this->classes=classes;
}
  
//function to display
void DisplayStudent()
{
cout<<"\nStudent ID: "<<this->ID<<
"\n"<<this->FirstName<<", "<<this->LastName<<".\n"
<<this->classes<<" Classes Taken This Semester"
<<"\nCurrent GPA is "<<this->GPA<<"\n\n";
}
//function to set all variables
void SetALL (string id,string lname,string fname, float gpa,int cls)
{
this->ID =id;
this->LastName=lname;
this->FirstName=fname;
this->GPA=gpa;
this->classes=cls;

}
};

int main()
{
Student s[6]; //array of objects
int n=4,cls;
string id,lname,fname;
float gpa;
char c;

//set all values
s[0].SetALL("AF101", "Zachery H" ,"Smith",3.2,4 );
s[1].SetALL("HJ389", "Alias T", "Jones",2,3.3);
s[2].SetALL("KL209","Emma P","Luzer",4,4);
s[3].SetALL("LL309"," Hill O","Beans",3,2.5);

//display
for(int i=0;i<n;i++)
s[i].DisplayStudent();

//get hit to continue
cout << "\nHit Any Key to continue...";
cin.get();
  
//get values from user
do
{
cout<<"\nEnter ID: ";
cin>>id;
cout<<"\nEnter LastName: ";
cin>>lname;
cout<<"\nEnter FirstName: ";
cin>>fname;
cout<<"\nEnter GPA: ";
cin>>gpa;
cout<<"\nEnter number of classes: ";
cin>>cls;
s[n].SetALL(id,lname,fname,gpa,cls); //add to class

cout<<"\nDo you want to continue (y/n):";
cin>>c;
}while(c=='y' && n<5);
return 0;
}

output:

İ DicppstudentclassibinDebuglstudentclass.exe tudent ID: AF101 mith. Zachery H Classes Taken This Semester urrent GPA is 3.2

//for any clarification, please do comments

Add a comment
Know the answer?
Add Answer to:
A class allows a group of one or more member objects to have a series of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...

  • in C++: Create a class named Student that has three member variables: name - string that...

    in C++: Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100. classList - an array of strings of size 100 used to store the names of the classes that the student is enrolled in Write the appropriate constructor(s), mutator and accessor functions for the class along with...

  • choices: supporting function default constructor friend function static member class getter setter attribute assignment operator Identify...

    choices: supporting function default constructor friend function static member class getter setter attribute assignment operator Identify the parts of the following class definition: class Student { string name; const int ID; float gpa; const char gender; public: Student(); Student& operator (const Student&); string getName() const {return name; } friend ostream& operator<<(ostream&, const Student); }; void outputStudent (const Student&); name [Choose Student) [Choose operator Choose) outputStudent Choose operator<< Choose) getNamel) [Choose

  • This is a simple C++ class using inheritance, I have trouble getting the program to work....

    This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...

  • Implement the following class in interface and implementation files. A separate file (the main project file)...

    Implement the following class in interface and implementation files. A separate file (the main project file) shall have the main function that exercises this class. Create a class named Student that has three member variables: name - string that stores the name of the student numClasses - integer that tracks how many courses the student is currently enrolled in, this number must be between 1 and 100 ClassList - an array of strings of size 100 used to store the...

  • 2. Write a program named lab3 2.app that contains a class named Student to store student...

    2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...

  • [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is...

    [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is read-only; 2)a getter and setter for the lecturer attribute, so that it is readable and writable; 3)a constructor that creates the associations shown in the UML diagram; 4)an enrolStudent method that adds a given Student object into the 'enrolled' set; 5)a withdrawStudent method that removes a given Student object from the 'enrolled' set and returns true if the student was successfully found and removed,...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides...

    Question 1 (24 Marks] 1. (4 marks) Write an immutable Person class in Java which provides the following. • Two attributes: lastName and first Name of type String. • Appropriate initialization, accessors/mutator methods. 2. (6 marks) Write a Student class that is a subclass of Person class (in the previous question) which provides the following. • Two attributes: A unique student ID of type String and GPA of type float; the student ID is initialized when a Student object gets...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT