Here is my question I had attached 4acpp file also and as we

Here is my question I had attached 4a.cpp file also and as well as sample outputs too. You need to add code to work properly.
2: need code as well as outputs also with my details.
o AT&T; 2:18 AM blackboard.saumag.edu 1. Lab5A Type Lab4A.cpp into the editor. Add your name and se your student ID where it says //[Your name here], and 1.1 Build and run Lab5A.cpp // Student // Name: // /Sect ion /I ID: // example: class constructor #1 nc l ude

Solution

// Student
// Name: Bharath kumar Nreddy
// Section: 003
// ID: 9999-92410
// example: class constructor

#include <iostream>
using namespace std;
#include <iomanip>
#include <sstream>

class Student{
  
private:
string name;
int idNum;
double gpa;
  
public:
Student () { }//initialize student object
Student(string, int, double);
string getName(){
//Return the name of the student;
return name;
}
//Write a function called getGPA that returns the GPA of the student.
double getGPA(){
//returns the GPA of the student.
return gpa;
}
//Write a function called getIdNum that returns the idNum
//of the student
double getIdNum(){
//returns the idNum of the student.
return idNum;
}
  
//Mutator: changes the student name
  
void setStudentName(string n){
name=n;
}
//Write a mutator called setGPA, which takes a double
//and changes the GPA of the student
void setGPA(double g){
gpa=g;
}
  
//call user defined toString function Returns a formatted string of student
string formatString(){
//for formating the idNum for the leading zero
stringstream ss;
ss << setw(9) << setfill(\'0\') << idNum;
string s1 = ss.str();
  
string s=\"Student name: \" + name +\"\ Student ID num: \"+ s1 +\"\ Student GPA: \"+ std::to_string(gpa) +\"\ \";
return s;
}
};

Student::Student(string a, int b, double c){
//save namePar to class variable name
name=a;
//save idNumPar to class variable idNum
idNum=b;
//save gpaPar to class variable gpa
gpa=c;
} //End of Student::Student

int main()
{
//Constant
const string NAME=\"Bharath kumar Nreddy\";
const int STUID=999992410;
const double GPA1=4.00;
const double GPA2=2.34;

Student stud1;
stud1= Student(NAME,STUID,GPA1);
cout<< \"\ Name: \"<<stud1.getName()<<endl;
cout<< \"Id Number: \"<<stud1.getIdNum()<<endl;
std::cout << std::setprecision(2);
cout<< \"GPA: \"<<setprecision(2)<< fixed <<stud1.getGPA()<<endl;

//setting the GPA using mutator
stud1.setGPA(GPA2);
cout<<stud1.formatString();

//Create a second student Object
//Write a name of Pistol Pete, a gpa of 4.00.
//and student id of 000000001

Student stud2;
const string NAME2=\"Pistol Pete\";
const int STUID2=000000001;
const double GPA3=4.00;
stud2=Student(NAME2, STUID2, GPA3);
//print out this student same as above
cout<< \"Name: \"<<stud2.getName()<<endl;
cout<< \"Id Number: \"<<stud2.getIdNum()<<endl;
cout<< \"GPA: \"<<setprecision(2)<< fixed <<stud2.getGPA()<<endl;
cout<<stud2.formatString();


return 0;
} //end of main


/*****************output****************/

Name: Bharath kumar Nreddy
Id Number: 9.99992e+08 GPA: 4.00
Student name: Bharath kumar Nreddy
Student ID num: 999992410 Student GPA: 2.340000
Name: Pistol Pete   
Id Number: 1.00
GPA: 4.00
Student name: Pistol Pete
Student ID num: 000000001
Student GPA: 4.000000
sh-4.3$ ^C

Note: I have taken your name and section from the 4a.cpp file. Please ask if you have any question. God Bless you !!

Here is my question I had attached 4a.cpp file also and as well as sample outputs too. You need to add code to work properly. 2: need code as well as outputs al
Here is my question I had attached 4a.cpp file also and as well as sample outputs too. You need to add code to work properly. 2: need code as well as outputs al
Here is my question I had attached 4a.cpp file also and as well as sample outputs too. You need to add code to work properly. 2: need code as well as outputs al

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site