Question

In: Computer Science

READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT COMFORTABLE WITH CLASSES,I...

READ THE FOLLOWING CAREFULLY TO GET FULL VALUE FROM THE PRACTICE. IF NOT COMFORTABLE WITH CLASSES,I WOULD START WITH DEFINING THE CLASS WITH ONE constructor AND GO FROM THEREUse the following to calculate a GPA (the following is for calculation information only):A = 4.00 grade points per credit hourA- = 3.70 grade points per credit hourB+ = 3.33 grade points per credit hourB = 3.00 grade points per credit hourB- = 2.70 grade points per credit hourC+ = 2.30 grade points per credit hourC = 2.00 grade points per credit hourC- = 1.70 grade points per credit hourD+ = 1.30 grade points per credit hourD = 1.00 grade points per credit hourD- = 0.70 grade points per credit hourgpa calculation = total grade points received (see above)/ number hours attemptedIf you took 3 classes; 3 credit hours each; received an 'A' in each classA = 4.00 points per credit hour means a total of 36 grade points earnedfor 9 attempted hoursgpa = 36/9 = 4.01. Create a header file (*.h) for a class named Student defined as follows:Private variables to hold:first namelast namestreet addresscitystatezipearned grade pointsattempted credit hoursgpaPublic methods:constructor of type Student; set all the private variables to spaceor zero, depending on the data typeconstructor of type Student; set all name values and all address values

to values passed in as parameters, do not include earned grade point orattempted credit hours as parametersconstructor of type Student; set ALL private variables to valuespassed in as parametersmethod to display all private variables of the class (i.e., cout)method to calculate the gpa (no parameters)method to calculate the gpa with earned and attempted values passed in as parametersmethod to set the earned value; earned value passed in as parametermethod to set the attempted value; attempted value passed in as parameter2. Create an implementation program (*.cpp file) for class Student and code all the public methods.3. Create a client program (*.cpp) that uses class Student. Create three students using each ofthe three constructors defined in 1. Be aware of what data gets initialized or set to values.4. Calculate the gpa for each of the students.5. Display ALL the data for each of the students after the gpa has been calculated (name, full address,grade points earned, grade points attempted, gpa)6. Be aware that if the first two constructors are used, the earned and attemptedvalues will NOT be set to calculate the gpa. Try using your set methodsto give these a value.You will need to create a project.If you like to include the following line of code: system("pause");You MAY need to: #include <cstdlib>Complete as much as you can before you submit ensuring what you've completed compiles. You do not have to correctlysolve the coding exercise, however, you MUST include code that ATTEMPTS to solve the problem to get credit.The program may be named any name of your choice and must have a .cpp extention. Do NOT includespaces in program names; variables may be any name of your choice.

Solutions

Expert Solution

Short Summary:

  • Provided the source code and screenshot of the same with Sample output.
  • Please upvote the answer and appreciate our time.

Source Code:

Student.h:

#ifndef STUDENT_H
#define STUDENT_H
#include <iostream>
using namespace std;

class Student {
// private variables
private:
string firstName;
string lastName;
string streetAddress;
string city;
string state;
int zip;
float earnedGradePoints;
int attemptedCreditHours;
float gpa;
  
// public methods
public:
Student();
Student(string,string,string,string,string,int);
Student(string,string,string,string,string,int,float,float);
void display();
void calculateGpa();
float calculateGpa1(float,int);
void setEarnedValue(float);
void setAttemptedValue(int);
};
#endif

Student.cpp:

#include "Student.h"
#include <iostream>
#include <string>
using namespace std;

// default constructor; all the private variables to space or zero
Student :: Student(){
firstName = " ";
lastName = " ";
streetAddress = " ";
city = " ";
state = " ";
zip = 0;
earnedGradePoints = 0.0;
attemptedCreditHours = 0;
gpa = 0.0;
}

// parameterized constructor; setting all name values and all address values
Student :: Student(string fName,string lName,string streetAdd,
string cty,string sta,int zipcode){
firstName = fName;
lastName = lName;
streetAddress = streetAdd;
city = cty;
state = sta;
zip = zipcode;
earnedGradePoints = 0.0;
attemptedCreditHours = 0;
gpa = 0.0;
}

// parameterized constructor; setting ALL private variables to values passed in as parameters
Student :: Student(string fName,string lName,string streetAdd,string cty,
string sta,int zipcode,float gradePoints,float creditHours){
firstName = fName;
lastName = lName;
streetAddress = streetAdd;
city = cty;
state = sta;
zip = zipcode;
earnedGradePoints = gradePoints;
attemptedCreditHours = creditHours;
gpa = 0.0;
}

// method to display all private variables of the class
void Student :: display(){
cout << "Name : " << firstName << " " << lastName << endl;
cout << "Address : " << streetAddress << " " << city << " " << state << " " << zip << endl;
cout << "Earned Grade Points : " << earnedGradePoints << " " << endl;
cout << "Attempted Credit Hours: "<< attemptedCreditHours << " " << endl;
cout <<"GPA: " << gpa << endl;
cout<<"-----------------------------------------------------" << endl;
}

// method to calculate the gpa (no parameters)
void Student :: calculateGpa(){
gpa = earnedGradePoints / attemptedCreditHours;
}


// method to calculate the gpa with earned and attempted values passed in as parameters
float Student :: calculateGpa1(float gradePoints,int creditHours){
return gradePoints / creditHours ;
  
}
// setter for earned value;
void Student :: setEarnedValue(float gradePoints){
earnedGradePoints = gradePoints;
}

  
// setter for attempted value
void Student :: setAttemptedValue(int creditHours){
attemptedCreditHours = creditHours;
}

main.cpp:

#include <iostream>
#include "Student.h"
using namespace std;

int main()
{
// Creating Student objects by calling different constructors
Student student1 = Student();
Student student2 = Student("Sara","Durgs","12","Atlanta","GA",30456);
Student student3 = Student("Jospeh","Rama","5","Ohio","OH",39573,36,9);
  
// calculating GPA for first student object
student1.setEarnedValue(28);
student1.setAttemptedValue(4);
student1.calculateGpa();
  
// calculating GPA for 2nd student object
student2.setEarnedValue(52);
student2.setAttemptedValue(12);
student2.calculateGpa();
  
// calculating GPA for 3rd student object
student3.calculateGpa();
  
// displaying the result
student1.display();
student2.display();
student3.display();

return 0;
}

Refer the following screenshots for code indentation:

Student.h:

Student.cpp:

main.cpp:

Sample Run:

******************************************************************************

Feel free to rate the answer and comment your questions, if you have any.

Please upvote the answer and appreciate our time.

Happy Studying!!!

******************************************************************************


Related Solutions

1. Medical clearance and risk stratification case study practice. Please carefully read the following case studies,...
1. Medical clearance and risk stratification case study practice. Please carefully read the following case studies, answer the questions and ultimately determine the need for medical clearance and appropriate risk stratification. A. Joe is a 49 years old male who stands tall at 5’11” andweighs 240 pounds. He currently smokes one half pack ofcigarettes a day and indicates no history of regular physicalactivity over the past 10 years. He also has a sedentaryoccupation and travels frequently for work. His latestphysical...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I...
I am posting this for the third time. PLEASE READ EVERYTHING CAREFULLY AND THEN ANSWER I am m designing a questionnaire for the topic: FACTORS INFLUENCING CONSUMER BUYING BEHAVIOR IN PURCHASE OF MILK IN ORGANIZED AND UNORGANIZED SECTOR. the study is basically to study the factors that influence consumer decisions in purchase of milk in organized and unorganized sector of milk. For this i need variables that influence purchase of milk in organized and unorganized sector. \ Note: I need...
Very carefully read the following data requirements for a prospective document translation database: i. Document translation...
Very carefully read the following data requirements for a prospective document translation database: i. Document translation initially relies on a source document. The source document is a text provided in the originally recorded, valid language (see below, and assume only one language for the original document), and has an associated author and publication date. Source document authors are not related to translators in any manner. ii. Translation of a document also relies on a translator, who is capable of translating...
Please read carefully. You must show all of your work for full credit. A correct answer...
Please read carefully. You must show all of your work for full credit. A correct answer with no work shown is worth no points, but an incorrect or partial answer with some work shown may be worth partial credit. Include explanations in each step. Correct format for writing answers (using symbols and letters). Question: What is the probability that fewer than 120 agreed? Answer: P (x < 120) I. An orange juice producer buys oranges from a large orange grove...
Choose one situation from the following given below. Read carefully and analyze the situation based on...
Choose one situation from the following given below. Read carefully and analyze the situation based on what you have learned from the previous readings that we tackled in class. Write a proposal addressing the concern in the given situation. Do note that you are already in the situation. You are not allowed to take precautionary measures before the situation happens.   Explain as to why you come up with your answers. It is best that you provide basis as your support....
Explain in detail with examples and full illustration to take get full credit. Copy from the...
Explain in detail with examples and full illustration to take get full credit. Copy from the internet or slides is not allowed. Evaluate three internal and three external recruitment channels.
what are the barriers impeding advanced practice nurses from achieving their full scope of practice
what are the barriers impeding advanced practice nurses from achieving their full scope of practice
Your project MUST do exactly what I am asking for. Read very carefully. I will take...
Your project MUST do exactly what I am asking for. Read very carefully. I will take point off. Show the output that I ask for in the text file and upload the file. When I run your project, if it does not match the given out put you get Zero. In addition, any two project that copies from each other get zero credit and report to the SMC disciplinary department. Advanced Java Programming Polymorphism, Class Design, Inheritance Assignment: You are...
I paid to be able to post question here. Please read carefully and give quality answer....
I paid to be able to post question here. Please read carefully and give quality answer. there is nothing to clarify. just do what is required. Do not mess up my question as there are limited. Thanks. Choose at least two concepts from the following: equity method, fair value method, partnership, corporation, bankruptcy chapter 7, bankruptcy chapter 11, subsidiary, parent company, consolidation of financial statements, trust, estates, liquidation, partnerships termination, estates tax, acquisition, variable interest entity, EPS, income tax, reorganization....
1. Read the following statement carefully: “The concepts of probability and statistics are powerful ones and...
1. Read the following statement carefully: “The concepts of probability and statistics are powerful ones and contribute extensively to the solutions of many types of engineering problems”. Answer the following: Why, in your own words, do you think in your specifically engineering professional practice, probability and statistics will help you to be successful?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT