Question

In: Computer Science

Create a student class that stores name, registration number and percentage, grade. Add member functions -...

Create a student class that stores name, registration number and percentage, grade. Add member functions
- Read( string n, int r, float p): Read function that accepts parameter
- Display(): To display student’s information
- CalculateGrade()

Solutions

Expert Solution

Program:

#include<iostream>
#include<string>
using namespace std;

class Student
{
string name;
int registrationNumber;
float percentage;
  
public:
void Read(string n, int r, float p)
{
name=n;
registrationNumber=r;
percentage=p;
}
  
void Display()
{
cout<<"\nStudent Information:\n";
cout<<"-------------------------------\n";
cout<<"Name: "<<name<<endl;
cout<<"Registration number: "<<registrationNumber<<endl;
cout<<"Percentage: "<<percentage<<endl;
}
void CalculateGrade()
{
if(percentage>=80 && percentage<=100)
{
cout<<"Grade : A";
}
else if(percentage>=60 && percentage<80)
{
cout<<"Grade : B";
}
else if(percentage>=40 && percentage<60)
{
cout<<"Grade : C";
}
else
{
cout<<"Grade : D";
}
  
}
};

int main()
{
string n;
int r;
float p;
cout<<"Enter Student name: ";
getline(cin,n);
cout<<"Enter Registration number: ";
cin>>r;
cout<<"Enter Percentage: ";
cin>>p;
Student stud;
stud.Read(n,r,p);
stud.Display();
stud.CalculateGrade();
return 0;
}

Output:


Related Solutions

Create a class called Student which stores • the name of the student • the grade...
Create a class called Student which stores • the name of the student • the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into the grade field. • Calculate the...
Question 1 (10) Create a class Student with public member variables: Student name, student number, contact...
Question 1 (10) Create a class Student with public member variables: Student name, student number, contact number, ID number. The following specifications are required:  Add init() method of the class that initializes string member variables to empty strings and numeric values to 0. (2)  Add the method populate() to the class. The method is used to assign values to the member variables of the class. (2)  Add the method display() to the class. The method is used...
For this program you will add and test 2 new member functions to the class in...
For this program you will add and test 2 new member functions to the class in //************************ intSLList.h ************************** // singly-linked list class to store integers #ifndef INT_LINKED_LIST #define INT_LINKED_LIST class IntSLLNode { public: IntSLLNode() { next = 0; } IntSLLNode(int el, IntSLLNode *ptr = 0) { info = el; next = ptr; } int info; IntSLLNode *next; }; class IntSLList { public: IntSLList() { head = tail = 0; } ~IntSLList(); int isEmpty() { return head == 0; }...
Create a class DogWalker member List <String>doggies method: void addDog(String name ) //add dog to the...
Create a class DogWalker member List <String>doggies method: void addDog(String name ) //add dog to the List method: void printDogList() //print all dogs in list /* You’ll need an index. Iterate over your list of dog names in a while loop. Use your index to “get” the dog at the current index When you ‘find’ your dog name in the list, print it out */ Method: void findDogUsingWhile(String dogName) /* You’ll need an index. Iterate over your list of dog...
C# Programming (Class Registration class) Add a Schedule property to the Person class. Add a new...
C# Programming (Class Registration class) Add a Schedule property to the Person class. Add a new behavior as well: add(Section s) this behavior will add a section to the Person’s schedule. The Person’s display() function will also need to be modified to display() the Person’s Schedule. Schedule class has Properties: An array of Sections and a Count. Constructors: only a default constructor is needed. Behaviors: add() and display(). This is my schedule class class Schedule     {         private int...
Create a UEmployee class that contains member variables for the university employee name and salary. The...
Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title. Write a runner program that creates one instance of each class and prints all of...
Create a class named Student. Student has fields for an ID number, number of credit hours...
Create a class named Student. Student has fields for an ID number, number of credit hours earned, and number of points earned. (For example, many schools compute grade point averages based on a scale of 4, so a three-credit-hour class in which a student earns an A is worth 12 points.) Include methods to assign values to all fields. Student also has a field for grade point average. Include a method to compute the grade point average field by dividing...
1. Please create a New Class with the Class Name: Class17Ex Please add the ten methods:...
1. Please create a New Class with the Class Name: Class17Ex Please add the ten methods: 1. numberOfStudents 2. getName 3. getStudentID 4. getCredits 5. getLoginName 6. getTime 7. getValue 8. getDisplayValue 9. sum 10. max Show Class17Ex.java file with full working please. Let me know if you have any questions.
#ifndef CCALC_HEADER #define CCALC_HEADER    class   CCalc { public:     // member functions     CCalc();     void    Add(double...
#ifndef CCALC_HEADER #define CCALC_HEADER    class   CCalc { public:     // member functions     CCalc();     void    Add(double value);     void    Clear();     void    Divide(double value);     double  GetValue() const;     void    Multiply(double value);     void    SetValue(double  newValue);     void    Subtract(double value);    private:     // data members     double  m_total; };    #endif // CCALC_HEADER int     main() {     CCalc       calculator;     char        choice;        // loop and let the user manipulate the calculator     do {         // display the menu and get the user selection         DisplayMenu();         cout <<...
1)  Create a UEmployee class that contains member variables for the university employee name and salary. The...
1)  Create a UEmployee class that contains member variables for the university employee name and salary. The UEmployee class should contain member methods for returning the employee name and salary. Create Faculty and Staff classes that inherit the UEmployee class. The Faculty class should include members for storing and returning the department name. The Staff class should include members for storing and returning the job title. Write a runner program that creates one instance of each class and prints all of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT