Question

In: Computer Science

using c plus plus: THE PROGRAMS SHOULD 3 DIFFERENT PARTS AS MAIN, STUDENTTYPE.H AND STUDENTTYPELMP.CPP. I...

using c plus plus: THE PROGRAMS SHOULD 3 DIFFERENT PARTS AS MAIN, STUDENTTYPE.H AND STUDENTTYPELMP.CPP. I ALWAYS GRADE MY ANSWERS. THANKS.

Chapter 9 defined the struct studentType to implement the basic properties of a student. Define the class studentType with the same components as the struct studentType, and add member functions to manipulate the data members. (Note that the data members of the class studentType must be private.)

Write a program to illustrate how to use the class studentType.

Struct studentType:

struct studentType
{
 string firstName;
 string lastName;
 char courseGrade;
 int testScore;
 int programmingScore;
 double GPA;
};

An example of the program is shown below:

Name: Sara Spilner
Grade: A
Test score: 89
Programming score: 92
GPA: 3.57

Solutions

Expert Solution

Code

STUDENTTYPE.H

#ifndef _STUDENTTYPE_H
#define _STUDENTTYPE_H
#include<string>
#include<iostream>
using namespace std;
class studentType
{
public:
   studentType(string,string,char,int,int,double);
   void setFirstname(string);
   void setLastname(string);
   void setCourseGrade(char);
   void setTestScore(int);
   void setProgramingScore(int);
   void setGPA(double);
   string getFirstname();
   string getLastname();
   char getCourseGrade();
   int getTestScore();
   int getProgramingScore();
   double getGPA();
private:
   string firstName;
   string lastName;
   char courseGrade;
   int testScore;
   int programmingScore;
   double GPA;
};
#endif

STUDENTTYPELMP.CPP

#include"STUDENTTYPE.h"

studentType::studentType(string fn,string ln,char cg,int tScore,int pScore,double gpa)
{
   firstName=fn;
   lastName=ln;
   courseGrade=cg;
   testScore=tScore;
   programmingScore=pScore;
   GPA=gpa;
}
char studentType::getCourseGrade()
{
   return courseGrade;
}
string studentType::getFirstname()
{
   return firstName;
}
string studentType::getLastname()
{
   return lastName;
}
int studentType::getProgramingScore()
{
   return programmingScore;
}
int studentType::getTestScore()
{
   return testScore;
}
double studentType::getGPA()
{
   return GPA;
}
void studentType::setCourseGrade(char cg)
{
   courseGrade=cg;
}
void studentType::setFirstname(string fn)
{
   firstName=fn;
}
void studentType::setGPA(double gpa)
{
   GPA=gpa;
}
void studentType::setLastname(string ln)
{
   lastName=ln;
}
void studentType::setTestScore(int tScore)
{
   testScore=tScore;
}
void studentType::setProgramingScore(int pScore)
{
   programmingScore=pScore;
}

Main.cpp

#include"STUDENTTYPE.h"
int main()
{
   studentType st("Sara","Spilner",'A',89,92,3.57);

   cout<<"Name: "<<st.getFirstname()<<" "<<st.getLastname()<<endl;
   cout<<"Grade: "<<st.getCourseGrade()<<endl;
   cout<<"Test score: "<<st.getTestScore()<<endl;
   cout<<"Programming score: "<<st.getProgramingScore()<<endl;
   cout<<"GPA: "<<st.getGPA()<<endl;
   return 1;
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

has anyone finished all the parts to the question Programs Plus is a retail firm that...
has anyone finished all the parts to the question Programs Plus is a retail firm that sells computer programs for home and business use. On December 31, 2019, its general ledger contained the accounts and balances shown below: Only finding bits and pieces on here. College accounting Programs Plus is a retail firm that sells computer programs for home and business use. On  December 31, 2019, its general ledger contained the accounts and balances shown below: ACCOUNTS BALANCES Cash $ 15,280...
Explain the different types of health insurance programs. What are the main differences among these programs?...
Explain the different types of health insurance programs. What are the main differences among these programs? How are they similar? Be sure to use terms that are unique to benefits, compensation, and human relations
Explain the different types of health insurance programs. What are the main differences among these programs?...
Explain the different types of health insurance programs. What are the main differences among these programs? How are they similar? Be sure to use terms that are unique to benefits, compensation, and human relations.
Using C++ 1. Create a main function in a main.cpp file. The main function should look...
Using C++ 1. Create a main function in a main.cpp file. The main function should look as follows int main() {return 0;} 2. Create an array. 3. Ask user to enter numbers in size of your array. 4. Take the numbers and store them in your array. 5. Go through your array and add all the numbers. 6. Calculate the average of the numbers. 7. Display the numbers, sum and average.
Using C language: (Note: If a family of 4, apply family of 3 cost plus the...
Using C language: (Note: If a family of 4, apply family of 3 cost plus the cost of 1 participant. K800 is the fixed cost for a family of 3.) A bus company organizes a tour. The tour is open for 4 days and participants can register for the number of days they would like to participate in the tour. Each participant would pay K 300 for the tour per day, a family of 3 would pay K 800 per...
compile and link two c programs from cmd prompt: using command gcc program1.c program2.h -o main...
compile and link two c programs from cmd prompt: using command gcc program1.c program2.h -o main but getting error undefined reference to scheduleFCFS not sure how to correct issue.
Describe two different advocacy programs and the program's main mission and the services provided
Describe two different advocacy programs and the program's main mission and the services provided
Complete parts (a) through (c) using the following data. Row 1: 1 3 3 4 4...
Complete parts (a) through (c) using the following data. Row 1: 1 3 3 4 4 4 5 6 6 7 Row 2: 90 82 76 76 90 72 80 90 55 70 A.) Find the equation of the regression line for the given data, letting Row 1 represent the x-values and Row 2 the y-values. Sketch a scatter plot of the data and draw the regression line. Input the values of the slope and intercept for the regression line...
3. Explain the four main components of GDP (i.e., C+I+G+(X-M)).
 3. Explain the four main components of GDP (i.e., C+I+G+(X-M)). 4. What is the difference between nominal and real GDP? 5. What is the consumer price index (CPI)?
I JUST NEED ANSWER FOR QTN C AND QUESTION THREE (3) PLEASE. QUESTION 3 SHOULD BE...
I JUST NEED ANSWER FOR QTN C AND QUESTION THREE (3) PLEASE. QUESTION 3 SHOULD BE 3 POINT DISCUSSION WITH REMCOMMENDATIONS CASE 4–20 Ethics and the Manager, Understanding the Impact of Percentage Completion on Profit—Weighted-Average Method [Course Objective B] Gary Stevens and Mary James are production managers in the Consumer Electronics Division of General Electronics Company, which has several dozen plants scattered in locations throughout the world. Mary manages the plant located in Des Moines, Iowa, while Gary manages the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT