Question

The following class class studentType { private: char firstName[25]; char lastName[25]; int testScore[4]; double averageScore; public:...

The following class
class studentType
{ private:
char firstName[25];
char lastName[25];
int testScore[4];
double averageScore;

public:
};

int main(){

studentType student[30];
}

Write c++ code ti create a constructor of studentType to initialize the member variables. Also write function to input values of the member variables and print the values

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here I am providing the code and explanation in the comments. I have coded according to your instructions. If you have doubts please comment

Code :-

Code in text format:-

#include<iostream>
#include<conio.h>
using namespace std;
class StudentType{       //creating a constructor
   private:
       char firstname[25]; //declaring the member variables
       char lastname[25];
       int testScore;
       double averageScore;
   public :
       void getDetails(void);   //fucntions to enter the details
       void putDetails(void);   //fucntion to display the details
};

void StudentType::getDetails(void){
   cout<<"Enter Student Details\n";       //taking the input
   cout<<"Enter firstname:";
   cin >> firstname;                   //taking the entered input to the variables
   cout<<"Enter the lastname:";
   cin>> lastname;
   cout<<"Enter the testscore:";
   cin>> testScore;
   cout<<"Enter the averagescore:";
   cin>> averageScore;
   cout<<"**************************\n";
  
  
}

void StudentType::putDetails(void){       //functions to display the details
   cout << "Student details:\n";
   cout<<"**************************\n";
   cout << "FirstName:" << firstname << "\nlastname:" << lastname << "\ntestscore:" << testScore <<"\naverage test score:" << averageScore;
}

int main(){
   StudentType s;
   s.getDetails();       //calling the fucntion to enter the details
   s.putDetails();       //displaying the details of the student
}

Output:-

Add a comment
Know the answer?
Add Answer to:
The following class class studentType { private: char firstName[25]; char lastName[25]; int testScore[4]; double averageScore; public:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ program Create a Student class that contains three private data members of stududentID (int), lastName...

    C++ program Create a Student class that contains three private data members of stududentID (int), lastName (string), firstName(string) and a static data member studentCount(int). Create a constructor that will take three parameters of studentID, lastName and firstName, and assign them to the private data member. Then, increase the studentCount in the constructor. Create a static function getStudentCount() that returns the value of studentCount. studentCount is used to track the number of student object has been instantiated. Initialize it to 0...

  • Please use C++ Chapter 9 defined the struct studentType to implement the basic properties of a...

    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...

  • In Java: Develop a simple class for a Student. Include class variables; StudentID (int), FirstName, LastName,...

    In Java: Develop a simple class for a Student. Include class variables; StudentID (int), FirstName, LastName, GPA (double), and Major. Extend your class for a Student to include classes for Graduate and Undergraduate. o Include a default constructor, a constructor that accepts the above information, and a method that prints out the contents FOR EACH LEVEL of the object, and a method that prints out the contents of the object. o Write a program that uses an array of Students...

  • A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double...

    A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double GPA(=(4.0*NumberOfAs+3.0*NumberOfBs+2.0*NumberOfCs+1.0*NumberOfDs)/( As+Bs+Cs+Ds+Fs)); Public data member, void setFirstName(string name); string getFirstName() const; void printFirstName() const; void getLastName(string name); string getLastName() const; void printLastName() const; void computeGPA(int NumberOfAs,int NumberOfBs,int NumberOfCs,int NumberOfDs,int NumberOfFs); double getGPA() const; double printGPA() const; A destructor and an explicit default constructor initializing GPA=0.0 and checking if GPA>=0.0 by try{}catch{}. Add member function, bool operator<(const Student); The comparison in this function based on...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • Write a code in C++ by considering the following conditions :- Tasks :- 1. Create a...

    Write a code in C++ by considering the following conditions :- Tasks :- 1. Create a class Employee (with member variables: char * name, int id, and double age). 2. Create a constructor that should be able to take arguments and initialize the member variables. 3. Create a copy constructor for employee class to ensure deep copy. 4. Create a destructor and de allocate the dynamic memory. 5. Overload the assignment operator to prevent shallow copy and ensure deep copy....

  • Complete the code MyImage and test in your own main Public class MyImage { private char[][]...

    Complete the code MyImage and test in your own main Public class MyImage { private char[][] pixels; private int imageSize; //constructor public MyImage(int imageSize) { pixels = new char[imageSize][imageSize]; for (int i = 0; i < imageSize; ++i) { for (int j = 0; j < imageSize; ++j) { pixels[i][j] = '.'; } } } //print image public void print(){ //add your code } //draw a triangle with '*' public void drawTriangle() { //add your code } //draw a diamond...

  • I need help implementing Student(const char initId [], double gpa) without using pointers. I don't know...

    I need help implementing Student(const char initId [], double gpa) without using pointers. I don't know how to initialize this with the passed in gpa value. Using C++, implement the member function specified in student.h in the implementation file, student.cpp Student(const char initId[], double gpa) { } This function will initialize a newly created student object with the passed in value. Helpful info: From student.h class Student    {    public:           Student(const char initId[], double gpa);           bool isLessThanByID(const...

  • Create a class called MazeSolver: public class MazeSolver {    private char[][] maze;    private int startx,                    &

    Create a class called MazeSolver: public class MazeSolver {    private char[][] maze;    private int startx,                     starty;   Public MazeSolver(String fileName) throws IOException   {      // create an object to read information from “fileName”      // read the maze dimension (row col) from the file      // Allocate the space for maze      // initialize array maze with contents of the file      // find startx and starty      printMaze(); // a method that prints the maze      // solveMaze() is a recursive method to solve the maze      if(solveMaze(maze,startx,starty))...

  • Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string...

    Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT