Assignment No. 02
CS201: Introduction to Programming
Total Marks: 20
Due Date: 27/01/2014
Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:
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.
The objective of this assignment is to provide hands on experience of:
Write a program using class(constructor, destructor, other member functions) to find the frequency of letters (small and capital alphabet or digit) from your student id character string. For example, frequency of letter ‘4’ in the string of a student id: “MC124514517” is 2.
You are required to write a program which contains a class myClass having the following data members:
and the following member functions:
The main() function should create an object of myClass and through this object member functions are called one by one. When the object is created then constructor of myClass should dynamically allocate the memory using new operator for your VUID and displays a message after storing the default id in data member character pointer str.
“Default Constructor is called and default id is MC123456789”
Similarly, setId() member function when called with your VUID passed as parameter, should set the value of data member character pointer str with your VUID.
getId() function should return the value of data member character pointer str to the main(), then following message with your VUID should be displayed:
“Your ID is MC120403765”
Finally countfunction() must get input (any alphabet) from user by displaying the message,
“Enter letter you want to count:”
Then this function counts frequency of the specified letter from your VUID and displays it.
Destructor at the end of the program should be called and display message:
“Destructor called… and object has destroyed”
Sample output of program:
Replies are closed for this discussion.
I checked it again..
even the one you posted few minutes ago..
but both are giving the same and only one error :(
1_change the variables name...
2_there r 2 places i think where mention the ID..that place give ur own ID.
3_give commenting according to this coding (functions) ...
and assignment is ready now.
i hv shown u, ur prog with output...then how can it possible..??
without any changing i compiled ur prog..
any ways thanks for the help and time...
I think there is something with the version of dev++ and windows...
I am using windows 8 64-bit and
dev c++ 5.5.3
If yours are different versions than mine, I think I must submit the assignment with the changes you mentioned earlier...
Over and all..
not think..but i'm sure hving same prob.
yes, should submit assign after changing..
no #include<iostream.h> aye ga mailka sis
yar koi help kr do na is assigmnt mai ni a rahi smj :(
faiza rasheed i hv posted now complete solution...
kon kon bna chuka ha assigmnt tell me
cs201 assigmnt ufffff