These are C Computer Science II programming problem Please

These are C++ ( Computer Science II ) programming problem. Please provide the detailed answer the following problems.

Create a class named Student that has the following member variables: first name (string), last name(string), student identification number(int), an integer array where the grades of all classes are stored, grade point average (gpa) (float). Write appropriate constructor, mutator and accessor functions for the class along with the following A function that inputs all values from the user (except for gpa) A function that outputs the names and gpa of students

Solution

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

class Student
{
   public:
       Student(string first,string last, int id,int num,int c_credit,int c_gpa);
       Student();
      
       void input();
       void output();
      
       const   string get_first_name();
       const string get_last_name();
       const int get_stu_id();
       const   int get_class_num();
       const   int get_class_credit();
       const int get_gpa();

       void set_first_name();
       void set_last_name();
       void set_stu_id();
       void set_class_num();
       void set_class_credit();
       void set_gpa();
      
       private: //cannot be accessed
           string first_name;
           string last_name;
           int stu_id;
           int class_num;
           int credit;
           int gpa;
};
   Student::Student()
   {
   first_name;
   last_name;
   stu_id;
   class_num;
   credit;
   gpa;
   }
          
   string const Student::get_first_name() //accessor get called from class student public
   {
       return first_name;
   }
   string const Student::get_last_name()
   {
       return last_name;
   }
   int const Student::get_stu_id()
   {
       return stu_id;
   }
   int const Student::get_class_num()
   {
       return class_num;
   }          
   int const Student::get_class_credit()
   {
   return credit;
   }
   int const Student::get_gpa()
   {
       return gpa;
   }
  
   void Student::set_first_name(string first) //mutator
   {
       first_name = first;
   }
   void Student::set_last_name(string last)
   {
       last_name = last;
   }
   void Student::set_stu_id(int id)
   {
       stu_id = id;
   }
   void Student::set_class_num(int num)
   {
       class_num = num;
   }
   void Student::set_class_credit(int c_credit)
   {
       credit = c_credit;
   }
   void Student::set_gpa(int c_gpa)
   {
       gpa = c_gpa;
   }
  
   void Student::input()            //accessor
   {
       int i;
       int count_gpa;
                                      
       cout<<\"Enter first name and last name:\"<<endl;
       cin>>first_name>>last_name;
       cin.ignore();
       cout<< \"Enter the Identity number of student: \"<<endl;
       cin >> stu_id;
       cin.ignore();
       cout<< \"Get number of classes taking this semester: \"<<endl;
       cin >> class_num;
       cin.ignore();
                          
           if(class_num>   0)
       {
               credit = new std::int[class_num];
               for(i=0;i<class_num;i++)
               {                  
                   cout<<\"Enter marks of first classes \" <<(i+1)<<endl;
                   cin>>credit[i];
                   count_gpa = credit[i];
               }
       }
           gpa = count_gpa/class_num;
              
   cout<< \'\ \'<<endl;
   }
  
   void Student::output()//output what user entered
{
   cout<< \"Student first name: \" << first_name <<endl;
   cout<< \"Student last name: \" << last_name <<endl;
   cout<< \"Student gpa: \" << gpa <<endl;
}

These are C++ ( Computer Science II ) programming problem. Please provide the detailed answer the following problems. Create a class named Student that has the
These are C++ ( Computer Science II ) programming problem. Please provide the detailed answer the following problems. Create a class named Student that has the
These are C++ ( Computer Science II ) programming problem. Please provide the detailed answer the following problems. Create a class named Student that has the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site