Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CS201 Introduction to Programming Assignment No. 3 Solution Spring Semester June 2013
#1



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


Problem Statement:

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.

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply
#2
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

0300-9520262
Get solution in 24 hour
|cpmputer & internetConfusedmileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  CS508- Modern Programming Languages Assignment No. 03 Solution January 2016 Vuhelper 0 4,560 01-20-2016, 05:43 PM
Last Post: Vuhelper
  CS401 assignment no 3 Solution 20th January 2016 Vuhelper 0 10,251 01-20-2016, 05:15 PM
Last Post: Vuhelper
  Human Computer Interaction (CS408) Assignment no 3 20th January 2016 Vuhelper 0 1,060 01-20-2016, 05:13 PM
Last Post: Vuhelper
  CS101 Introduction to Computing Assignment No.2 Solution Spring Semester 2013 Vuhelper 4 12,094 12-13-2014, 01:23 AM
Last Post: Vuhelper
  ENG101 English Comprehension Assignment No.1 Solution Spring Semester 2013 Vuhelper 3 4,604 11-25-2014, 03:35 PM
Last Post: Vuhelper
  MGT101 Financial Accounting Assignment 2 Solution Spring Semester June 2013 Vuhelper 0 3,071 06-15-2013, 11:57 PM
Last Post: Vuhelper
  ISL201 Islamic Studies Assignment No.1 Solution Spring Semester 2013 Vuhelper 0 4,561 05-17-2013, 09:33 PM
Last Post: Vuhelper
  CS201 Introduction to Programming Assignment No.2 Solution Spring Semester 2013 Vuhelper 5 6,527 05-17-2013, 02:55 AM
Last Post: Xpert
  ENG201 Assignment No.2 Solution Spring Semester 2013 Vuhelper 1 5,744 05-16-2013, 04:41 PM
Last Post: Vuhelper
  ENG001 Elementary English Assignment No. 2 Solution Spring Semester 2013 Vuhelper 0 3,997 05-14-2013, 10:20 PM
Last Post: Vuhelper

Forum Jump:


Users browsing this thread: 1 Guest(s)