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.
thanks for the question, the question is missing the previous studentType struct, nevertheless I have demonstrated how you need to create the same struct as a class.
I have used two strings for the first and last name, one double for GPA score and one int for id. You can add any more number of instance variables in the class.
At the end i have created one main() class that sets the values to a object using setter member functions and later prints them using the getter functions.
Make sure you create 3 files as given in the screenshot.
==============================================================
#ifndef STUDENTTYPE_H
#define STUDENTTYPE_H
#include<string>
using std::string;
class StudentType
{
public:
StudentType();
StudentType(string,string,double,int);
void setFirstName(string);
void setLastName(string);
void setGPA(double);
void setStudentID(int);
string getFirstName()const;
string getLastName() const;
string getFullName() const;
double getGPA()const;
int getStudentID() const;
private:
string firstName;
string lastName;
double GPA;
int studentID;
};
#endif
===============================================================
#include "StudentType.h"
#include<string>
using std::string;
StudentType::StudentType():
firstName(""),lastName(""),GPA(0.0),studentID(0){
}
StudentType::StudentType(string fname, string lname, double gpa,
int id):
firstName(fname),lastName(lname),GPA(gpa),studentID(id){
}
void StudentType::setFirstName(string name){
firstName=name;
}
void StudentType::setLastName(string name){
lastName=name;
}
void StudentType::setGPA(double gpa){
GPA=gpa;
}
void StudentType::setStudentID(int id){
studentID=id;
}
string StudentType::getFirstName()const { return
firstName;}
string StudentType::getLastName() const{return lastName;}
string StudentType::getFullName() const {return firstName+"
"+lastName;}
double StudentType::getGPA()const {return GPA;}
int StudentType::getStudentID() const {return studentID;}
===============================================================
#include "StudentType.h"
#include <iostream>
#include<string>
using namespace std;
int main(){
StudentType sam = StudentType();
sam.setFirstName("Samuel");
sam.setLastName("Gomez");
sam.setGPA(4.7);
sam.setStudentID(123);
cout<<sam.getFullName()<<endl
<<"Student ID:
"<<sam.getStudentID()<<endl
<<"GPA Score:
"<<sam.getGPA()<<endl;
}
===============================================================

chapter 9 defined the struct studentType to implement the basic properties of a student. Define the...
Please use C++ 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...
Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also, declare an array of 10 components of type bankAccount to process up...
Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add the function print to this class to output the radius, area, and circumference of a circle.) Now every cylinder has a base and height, where the base is a circle. Design a class cylinderTypethat can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class circleTypedesigned in Chapter 10. Some of the operations that can...
C++ problem 11-3 Chapter 10 defined the class circleType to implement the basic properties of a circle. (Add the function print to this class to output the radius, area, and circumference of a circle.) Now every cylinder has a base and height, where the base is a circle. Design a class cylinderType that can capture the properties of a cylinder and perform the usual operations on the cylinder. Derive this class from the class circleType designed in Chapter 10. Some...
c++ please Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member func- tions to manipulate an object. Use a static member in the class to automatically assign account numbers. Also declare an array of 10 compo- nents of...
Please hlep as I've tried this C++ program and keep coming up with the wrong syntax somewhere. I need help defining the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder’s name (string), account number (int), account type (string, checking/saving), balance (double), and interest rate (double). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static member in...
Write one for all three files in c++
E MISLI UCCIONS if Instructions Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder's name ( string ), account number ( int ), account type ( string , checking/saving), balance ( double ), and interest rate (double ). (Store interest rate as a decimal number.) Add appropriate member functions to manipulate an object. Use a static...
Part 1. (60 pts) 1. Define an Address class in the file Address.h and implement the Address class in Address.cpp. a. This class should have two private data members, m_city and m_state, that are strings for storing the city name and state abbreviation for some Address b. Define and implement public getter and setter member functions for each of the two data members above. Important: since these member functions deal with objects in this case strings), ensure that your setters...
C++ Define the class bankAccount to implement the basic properties of a bank account. An object of this class should store the following data: Account holder
This lab will exercise your understanding of some of the concepts covered in Chapter 12: virtual functions (think about compile-time and run-time binding) 1. We will be treating the PersonType object as a base class that may be inherited by multiple objects. We will treat the personType getAddress and setAddress as pure virtual because we wish to have all inherited objects to code these functions but do not need them in the base class. Using the code for person type...