Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This should be written in C++. Create a class with the name \"Student\". private

ID: 3804213 • Letter: T

Question

This should be written in C++.

Create a class with the name "Student".

private data members of the Student class should include:

int - rollno (roll number or id number of student)

string - name (name of student)

int - alg, datastruct, architect, proglang (hold scores out of 100 for these 4 classes)

float - per (average score of 4 classes above)

char - grade (letter grade based on per.. example 90 is an A)

public member functions of the Student class should include:

getdata() (function to accept data from user

showdata() (function to show data on screen

Create a constructor that initializes all int to 0, float to 0.0, char to ' ', name = "NoName".

Prompt the user for a valid class size.

Prompt the user for student data.

Store students in a vector.

Display student data including students average score and letter grade.

The following is an example:

Explanation / Answer

Here is the code for above scenario:

#include <iostream>
using namespace std;

class Student{
private:
int rollno,alg, datastruct, architect, proglang;
string name;
float per;
char gra;
  
public:
void getdata(int alg,int datastruct,int architect,int rollno,int proglang,string name,float per,char gra){
this->alg = alg;
this->datastruct = datastruct;
this->architect = architect;
this->rollno = rollno;
this->proglang = proglang;
this->name = name ;
this->per = per ;
this->gra = gra;
}
void showdata(){
cout<<"Roll number of the student"<<rollno;
cout<<"Name of student:"<<name;
cout<<"Grade in Algorithms"<<alg;
cout<<"Grade in Data Structures:"<<datastruct;
cout<<"Grade in Architecture:"<<architect;
cout<<"Grade in Programming Languages: "<<proglang;
per = (alg+datastruct+architect+proglang)/4;
cout<<"Percentage of student is:"<<per;
if(per>=90 && per <=100){
gra = 'A';
}
if(per>=80 && per <=89){
gra = 'B';
}
if(per>=70 && per <=79){
gra = 'C';
}
if(per>=60 && per <=69){
gra = 'D';
}
if(per>=50 && per <=59){
gra = 'E';
}
if(per<=40 && per >=0){
gra = 'F';
}
cout<<"Grade of student is:"<<gra;
}
}
Student::Student() {
alg = 0;
datastruct = 0;
architect = 0;
rollno = 0;
proglang =0 ;
name = "NoName" ;
per = 0.0 ;
gra = '';
}
int main() {
  
vector<Student> list;
int rollno,alg, datastruct, architect, proglang;
string name;
float per;
char gra;
int n;
Student *s1;
cout<<"Enter size of class:";
cin>>n;
if(n>0){
for (int n=0; n<3; n++)
{
cout<<"Enter the roll number of student:";
cin>>rollno;
cout<<"Enter The Name of student:";
getline(cin,name);
cout<<"Enter the grade in Algorithms out of 100:";
cin>>alg;
cout<<"Enter the grade in Data Structures out of 100: ";
cin>>datastruct;
cout<<"Enter the grade in Architecture out of 100: ";
cin>>architect;
cout<<"Enter the grade in Programming Languages out of 100:";
cin>>proglang;
  
s1 = new Student;
s1.getdata(alg, datastruct, architect,rollno,proglang,name,per,gra);
list.push_back(*s1);
  
}

// Now setup an iterator loop through the vector
vector<Student>::iterator it;

for ( it = list.begin(); it != list.end(); ++it ) {
// For each friend, print out their info
it->showdata();
}
}
else{
cout<<"Invalid class size";
}

   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote