VUSuperior Chat Room

Tuesday, 8 July 2014

CS201-Introduction to Programming Assignment No.2 Solutions and Discussions Spring 2014 Due Date: 14th July 2014

Assignment No. 02
                        Semester: Spring 2014
             CS201: Introduction to Programming
Total Marks: 20

Due Date: 14/07/14


Instructions:

Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:



The assignment is submitted after due date.
The submitted assignment does not open or file is corrupt.
Assignment is copied(partial or full) from any source (websites, forums, students, etc)


Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files or .exe file, no reward will be given in any case.





Objective:



The objective of this assignment is to provide hands on experience of:



Basic concepts of C/C++ classes and objects
Dealing with Data members and member functions
Initialization of objects
Constructor
Destructor




Guidelines:



Code should be properly indented and well commented.
Follow C/C++ rules while writing variable names, function names etc
Use only dev-C++ for this assignment.



























Assignment 

Problem Statement:    



You are required to write a C++ program which contains a class studentInfo having  following data members:



Student ID
Course ID
Course Name
        

The class must have the following member functions:



Parameterized constructor
Setter functions 
Getter functions
Display function


Detailed Description:



Parameterized constructor: It should take three strings as arguments (Student Id, Course Id and Course Name) and initializes the data members of class using setter functions

Setter functions: There must be a setter function for each data member of class

Getter functions: There must be a getter function for each data member of class 

Display function: It should display the values of each data member of class by calling getter functions.



Within main() function, create an object of studentInfo class by using the parameterized constructor and pass three strings (student id, course id and course name) as arguments to this parameterized constructor. Then, call the display function which will display the values of student id, course id and course name.



You must display your own VU Id.



Sample output of program:

3 comments:

  1. Dear Students Don’t look ahead to resolution post your issues here and discuss ... once discussion an ideal resolution can are available a result. So, begin it currently, replies here provide your comments in line with your information and understandings.

    ReplyDelete
  2. #include

    using namespace std;

    class StudentInfo {
    private:
    char studentID[11];
    char courseID[6];
    char courseName[25];
    public:
    StudentInfo( char *studentID, char *courseID, char *courseName){
    strcpy(this->studentID,studentID);
    strcpy(this-> courseID,courseID);
    strcpy(this-> courseName, courseName);
    }

    void setStudentId(char *id){
    strcpy(studentID, id);
    }
    void setCourseId(char *cid){
    strcpy(courseID, cid);
    }

    void setCourseName(char *name){
    strcpy(courseName, name);
    }

    char * GetStudentID (){
    return studentID;
    }
    char * GetCourseID(){
    return courseID;
    }
    char * GetCourseName(){
    return courseName;
    }

    void Display(){
    cout << "Student Id :" << studentID << endl;
    cout << "Course Id :" << courseID << endl;
    cout << "Course Name :" << courseName << endl;

    }
    };

    main(){
    StudentInfo s1( XXXXXXX" , "CS201" , "Introduction to programming");
    s1.Display();


    cout<<endl;

    system("pause");

    }

    ReplyDelete
  3. #include
    using namespace std;

    class studentInfo{
    private:
    double studentID;
    char courseName[15];
    double courseID;
    public:
    void display();
    void setstudentID(int i);
    void setcourseName(char a[15]);
    void setcourseID(int i);
    int getstudentID();
    int getcourseName();
    int getcourseID();
    studentInfo(int StudentID,int CourseID, char CourseName[15]);

    };

    studentInfo::studentInfo(int StudentID, int CourseID, char CourseName[15])
    {
    StudentID= StudentID;
    CourseName= CourseName;
    CourseID = CourseID;
    }

    void studentInfo::display()
    {
    cout Student Info is getStudentID()end1getcourseID()endlgetcourseName()end1;

    }

    void studentInfo::setstudentID(int i)
    {
    studentID = i;
    }

    void studentInfo::setcourseID(int i)
    {
    courseID= i;
    }
    void studentInfo::setcourseName(char a[15])
    {
    courseName= a;
    }
    int studentInfo::getstudentID()
    {
    return studentID;
    }
    int studentInfo::getcourseName()
    {
    return courseName;
    }
    int studentInfo::getcourseID()
    {
    return courseID;

    }

    ReplyDelete