Sponsored Links


Results 1 to 6 of 6

Thread: CS201 Assignment 4 Solution, June 2010

  1. #1
    Senior Member viki's Avatar
    Join Date
    May 2010
    Posts
    2,132

    99 CS201 Assignment 4 Solution, June 2010

    Sponsored Links


    Code:
    Solution:-
     
    #include <iostream>
    using namespace std;
    class Student{
    private:
    string name;
    int rollNumber;
    string semester;
    double cgpa;
    
    public:
    Student(string n,int r,string s,double c )
    {name=n;
    rollNumber=r;
    semester=s;
    cgpa=c;
    }
    Student()
    {name="";
    rollNumber=0;
    semester="Summer 2010";
    cgpa=4.0;
    }
    
    
    string get_semester()
    {return semester;
    }
    void set_semester(string n)
    {semester=n;
    }
    void set_roll(int n)
    {rollNumber=n;
    }
    int get_roll()
    {return rollNumber;
    }
    void set_name(string n)
    {name=n;
    }
    string get_name()
    {return name;
    }
    void set_cgpa(double n)
    {cgpa=n;
    }
    
    double get_cgpa()
    {return cgpa;
    }
    void print()
    {cout<<"Student Information\n";
    cout<<"Name: "<<name<<endl;
    cout<<"Roll number: "<<rollNumber<<endl;
    cout<<"Semester: "<<semester<<endl;
    cout<<"Current GPA: "<<cgpa<<endl<<endl;
    }
    };
    
    int main()
    {Student a;
    Student b("name",2345,"Spring 2010",3.5);
    a.print();
    b.print();
    system("pause");
    return 0;
    }


    Sponsored Links
    :o:o--------------------------------------------------------------------------------------:o:o
    [B]The more knowledge you have, the greater will be your fear of Allah.[/B]

    Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
    [B]http://vuhelp.net/groups/birthday-wishing.html[/B]
    [B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
    [CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]

  2. #2
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Nice code, one confusion though, why we are using setter and getter, while they are not used in intmain(); just because assigment mentioned them. I mean maybe we can make use of them/

  3. #3
    Junior Member
    Join Date
    Jul 2010
    Posts
    2
    Instead we can enhance your print function in such a way to use getter function,

    void print()
    {cout<<"Student Information\n";
    cout<<"Name: "<<get_name<<endl;
    cout<<"Roll number: "<<get_roll<<endl;
    cout<<"Semester: "<<get_semester<<endl;
    cout<<"Current GPA: "<<get_cgpa<<endl<<endl;
    }

    Just a thought,

  4. #4
    Senior Member viki's Avatar
    Join Date
    May 2010
    Posts
    2,132
    Quote Originally Posted by ZalimJin View Post
    Instead we can enhance your print function in such a way to use getter function,

    void print()
    {cout<<"Student Information\n";
    cout<<"Name: "<<get_name<<endl;
    cout<<"Roll number: "<<get_roll<<endl;
    cout<<"Semester: "<<get_semester<<endl;
    cout<<"Current GPA: "<<get_cgpa<<endl<<endl;
    }

    Just a thought,
    hmmmmmmm
    :o:o--------------------------------------------------------------------------------------:o:o
    [B]The more knowledge you have, the greater will be your fear of Allah.[/B]

    Please Join My [B]Group Vuhelp[/B][B], Birthday Wishing, Daily Hadees[/B] [CODE][B]http://vuhelp.net/groups/vuhelp.html[/B]
    [B]http://vuhelp.net/groups/birthday-wishing.html[/B]
    [B]http://vuhelp.net/groups/daily-hadees.html[/B][/CODE]
    [CENTER][B][COLOR="Red"][SIZE="4"]Email: [email]viki@vuhelp.net[/email][/SIZE][/COLOR][/B][/CENTER]

  5. #5
    Senior Member Guru's Avatar
    Join Date
    May 2010
    Location
    Jhelum
    Posts
    117
    thanks viki.

  6. #6
    Senior Member sanam's Avatar
    Join Date
    May 2010
    Location
    sky
    Posts
    217
    thanks for the cs201 solution

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 06-24-2013, 10:39 PM
  2. Replies: 15
    Last Post: 01-11-2012, 05:19 PM
  3. Replies: 5
    Last Post: 06-15-2011, 04:35 AM
  4. CS201 Assignment 4 Solution Last Date 15 July 2010
    By Guru in forum Assignments & Solutions
    Replies: 1
    Last Post: 07-16-2010, 12:57 AM
  5. CS201 Solution 2nd Assignment Spring 2010 May 4
    By viki in forum Assignments & Solutions
    Replies: 0
    Last Post: 05-04-2010, 10:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft