Sponsored Links


Results 1 to 2 of 2

Thread: CS201 Introduction to Programming Assignment No. 3 Solution Spring Semester June 2013

  1. #1
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578

    18 CS201 Introduction to Programming Assignment No. 3 Solution Spring Semester June 2013

    Sponsored Links1





    CS201 Introduction to Programming Assignment No. 3 Solution Spring Semester June 2013


    Problem Statement:

    Sponsored Links

    Write the C++ program having class name studentinfo, that is used to store the VU student information: This class should store your VUID, campus id, name and father name in the following character type data members:

    Data members:

    VUID
    campusID
    Studentname
    Fathername

    Studentinfo class should have the parameterized constructor that is used to initialize the data members of the studentinfo class,

    Studentinfo class should have following member functions.

    Storefile()
    Display()

    Storefile() member function should store the value of all data members in the text file named “record.txt”, on separate lines in the text file as follows:
    ms120400400

    Vlhr02

    Muhammad Hussain

    Muhammad Ali.

    Display() member function reads your VUID, campusID, name and father name from the file named “record.txt”, stores them in the respective data members and displays the record.

    Hint:

    In main() function, create the object of the class by using parameterized constructor and then call the storefile() member function to store the record of all the data members in the text file. Finally call the display() function to read the data from text file and store it in the respective data members and display all the records.

  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    Idea Solution:

    #include<iostream.h> #include<conio.h> #include<fstream.h> class Studentinfo { private: char ID[50]; char campus[50]; char name[50]; char Father[50]; public: Studentinfo() { ID[50] = '\0'; campus[50] = '\0'; name[50]= '\0'; Father[50] = '\0'; } Studentinfo(char id[50] ,char c[50] ,char nam[50], char fthr[50]) { ID[50] = id[50]; campus[50] = c[50]; name[50] = nam[50]; Father[50] = fthr[50]; } void in() { cout"Enter your Vu ID "; cin>>ID; cout"Enter your Campus ID: "; cin>>campus; cout"Enter your Name: "; cin>>name; cout"Enter your Father Name: "; cin>>Father; } void Storefile() { cout"Al the Data members are stored in file \n"; ofstream file("D:\\test.txt"); if(!file) { cout"File opening error"; exit(1); } fileIDendlcampusendlnameendlFatherendl; file.close(); } void disply() { cout"M. Anil Kapoor \n\n"; cout"BC12301299\n\n"; cout"Following is your data\n\n"; ifstream in("D:\\record.txt"); if(!in) { cout"Error in opening file "; exit(1); } in>>ID; in>>campus; in>>name; in>>Father; cout"VU ID: "IDendl; cout"camp

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 05-17-2013, 02:55 AM
  2. Replies: 1
    Last Post: 04-27-2013, 03:02 PM
  3. Replies: 0
    Last Post: 06-30-2012, 04:41 PM
  4. Replies: 0
    Last Post: 06-21-2012, 04:26 PM
  5. Replies: 0
    Last Post: 06-09-2012, 05:56 AM

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