We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Looking For Something at vustudents.ning.com? Click Here to Search

www.bit.ly/vucodes

+ Link For Assignments, GDBs & Online Quizzes Solution

www.bit.ly/papersvu

+ Link For Past Papers, Solved MCQs, Short Notes & More


Dear Students! Share your Assignments / GDBs files as you receive in your LMS, So it can be discussed/solved timely. Files Upload Here.

CS201: Introduction to Programming Assignment No. 03 Semester: Spring 2013 Due Date:26/06/2013

Assignment No. 03
Semester: Spring 2013

CS201: Introduction to Programming

Total Marks: 20

 

Due Date:26/06/2013

 

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 or .zip no reward will be given in any case.

 

 

Objective:

 

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

 

  • Basic concepts of classes and objects in C/C++ language
  • Dealing with member functions
  • Parameterized constructors
  • File handling

 

 

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:     

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.

 

Sample Output:

 

Note: You have to upload only .cpp file of your assignment, do not send your assignment in .txt, .zip, .rar .doc or .docx format.

 

+ How to Follow the New Added Discussions at Your Mail Address?

+ How to Join Subject Study Groups & Get Helping Material?

+ How to become Top Reputation, Angels, Intellectual, Featured Members & Moderators?

+ VU Students Reserves The Right to Delete Your Profile, If?


See Your Saved Posts Timeline

Views: 6334

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

+ Click Here to Search (Looking For something at vustudents.ning.com?)

+ Click Here To Join (Our facebook study Group)

Attachments:

Replies to This Discussion

//CS201 Introduction to Programming 
//Assignment No. 03 Solution 
//Spring 2013
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;


class StudentInfo
{

char* vuId;
char* campusId;
char* studentName;
char* fatherName;

public:

StudentInfo(char* vu_Id, char* campus_Id, char* student_Name, char* father_Name)
{
cout "Parameterized constructor is called." endl;

setVuId(vu_Id);
setCampusId(campus_Id);
setStudentName(student_Name);
setFatherName(father_Name);
}

void setVuId(char* vu_Id)
{
vuId = new char[strlen(vu_Id) + 1];
strcpy(vuId, vu_Id);
}
void setCampusId(char* campus_Id)
{
campusId = new char[strlen(campus_Id) + 1];
strcpy(campusId, campus_Id);
}
void setStudentName(char* student_Name)
{
studentName = new char[strlen(student_Name) + 1];
strcpy(studentName, student_Name);
}
void setFatherName(char* father_Name)
{
fatherName = new char[strlen(father_Name) + 1];
strcpy(fatherName, father_Name);
}
void storeFile()
{
cout "All the data members are stored in file." endl;

ofstream outFile;
char* outputFileName = "record.txt";
outFile.open(outputFileName, ios::out);
if(!outFile)
{
cout "\n Unable to open file." endl;

}
else
{

outFile vuId;
outFile endl;
outFile campusId;
outFile endl;
outFile studentName;
outFile endl;
outFile fatherName;

}
}
void display()
{

ifstream inputStream;
char* fileName = "record.txt";
inputStream.open(fileName);
if(!inputStream)
{
cout "\nCan't Open the file for read";
}
else
{

char line[100];
inputStream.getline(line, 100);
setVuId(line);
inputStream.getline(line, 100);
setCampusId(line);
inputStream.getline(line, 100);
setStudentName(line);
inputStream.getline(line, 100);
setFatherName(line);
cout "Following is your data:" endl;
cout vuId endl;
cout campusId endl;
cout studentName endl;
cout fatherName;
cout endl;
}

}

};
int main()
{

StudentInfo studentInfo("ms120400400", "Vlhr02", "Muhammad Hussain", "Muhammad Ali.");
studentInfo.storeFile();
studentInfo.display();
system("pause");
return 0;
}

yah kas tarah kam kr re ga 5.1.0.0 main

insertion operator nai osay dalo ""

Ye error kesy resolve hoga? Reply fast please.

kon sa dev c++ ka version kaam kar raha h????????????

kam sab kr rhay hain agar app ko gcc char * error a rha ha devc++ mein its mein new gcc are not sported char *

#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
class studentinfo
{
char* VUID;
char* campusID;
char* Studentname;
char* Fathername;

public: 
studentinfo(char* vu_Id, char* campus_Id, char* student_Name, char* father_Name)
{
cout "Parameterized constructor is called." endl;
setVuId(vu_Id);
setCampusId(campus_Id);
setStudentName(student_Name);
setFatherName(father_Name);
}

void setVuId(char* vu_Id)
{
VUID = new char[strlen(vu_Id) + 1];
strcpy(VUID, vu_Id);
}
void setCampusId(char* campus_Id)
{
campusID = new char[strlen(campus_Id) + 1];
strcpy(campusID, campus_Id);
}
void setStudentName(char* student_Name)
{
Studentname = new char[strlen(student_Name) + 1];
strcpy(Studentname, student_Name);
}
void setFatherName(char* father_Name)
{
Fathername = new char[strlen(father_Name) + 1];
strcpy(Fathername, father_Name);
}
void storeFile()
{
cout "All the data members are stored in file." endl;
ofstream outFile;
char* outputFileName = "record.txt";
outFile.open(outputFileName, ios::out);
if(!outFile)
{
cout "\n Unable to open file." endl;

}
else
{
outFile VUID;
outFile endl;
outFile campusID;
outFile endl;
outFile Studentname;
outFile endl;
outFile Fathername;

}
}
void display()
{
ifstream inputStream;
char* fileName = "record.txt";
inputStream.open(fileName);
if(!inputStream)
{
cout "\nCan't Open the file for read";
}
else

char line[100];
inputStream.getline(line, 100);
setVuId(line);
inputStream.getline(line, 100);
setCampusId(line);
inputStream.getline(line, 100);
setStudentName(line);
inputStream.getline(line, 100);
setFatherName(line);
cout "Following is your data:" endl;
cout VUID endl;
cout campusID endl;
cout Studentname endl;
cout Fathername endl;
}

}

};
int main()
{
studentinfo obj("ms120400400", "Vlhr02", "Muhammad Hussain", "Muhammad Ali.");
obj.storeFile();
obj.display();
system("pause");
return 0;
}

bhai is program mein errors hain plz koi error free program upload ker den

RSS

Latest Activity

zuha shah posted a discussion
1 minute ago
Nabeel Ahmed joined + M.Tariq Malik's group
4 minutes ago
+EniE MeNiE replied to + Iuuoɔǝut +'s discussion بعد مُدت اُسے دیکھا، لوگو
6 minutes ago
+ ! ! ! ! Mehαr Mαh꧂ liked + M.Tariq Malik's discussion PSY101 Introduction to Psychology Assignment No 01 Fall 2019 Solution & Discussion
23 minutes ago
+¢αяєℓєѕѕ gιяℓ posted discussions
31 minutes ago
+ ! ! ! ! Mehαr Mαh꧂ replied to + ! ! ! ! Mehαr Mαh꧂'s discussion Assignment #1 MCM511 Theories of Communication fall 2019 in the group MCM511 Theories of Communication
48 minutes ago
+¢αяєℓєѕѕ gιяℓ replied to +¢αяєℓєѕѕ gιяℓ's discussion Mera tu Mohabbat se aitbar.............:-P
53 minutes ago
+ ! ! ! ! Mehαr Mαh꧂ liked + ! ! ! ! Mehαr Mαh꧂'s discussion Assignment #1 MCM511 Theories of Communication fall 2019
55 minutes ago
+ Iuuoɔǝut + posted discussions
1 hour ago
彡JK彡 ❤️ replied to Aijaz khan's discussion CS510 Assignment Fall 2019 Need Solution
3 hours ago
彡JK彡 ❤️ liked Aijaz khan's discussion CS510 Assignment Fall 2019 Need Solution
3 hours ago
Aijaz khan posted a discussion
5 hours ago
HaMza Tufail added a discussion to the group CS519 Final Project
6 hours ago
HaMza Tufail joined + M.Tariq Malik's group
7 hours ago
Fatima joined + M.Tariq Malik's group
8 hours ago
Adnan Hafeez replied to MIT's discussion Visual Programing (CS411) Assignment#01 Deadline Date = 18-11-2019 in the group CS411 Visual Programming
8 hours ago
Shine--Ex-VUStudent liked ١ دن's discussion زندگی گزارنے کا فارمولا
8 hours ago
HaMza Tufail added a discussion to the group CS420 Web Development for Portable Devices
9 hours ago
HaMza Tufail updated their profile
9 hours ago
١ دن replied to + Iuuoɔǝut +'s discussion بعد مُدت اُسے دیکھا، لوگو
9 hours ago

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service