You are on page 1of 2

National University of Computer and Emerging Sciences, Lahore Campus

Course: Computer Programming Course Code: CL-103


Program: BS (Computer Science) Semester: Spring 2018
Duration: 150 Minutes Total Marks: 50
Paper Date: 07 May 2018 Weight 40%
Section: All Page(s): 2
Exam: Final Term Reg. No
Instruction/Notes:
1. Understanding the question paper is also part of the exam, so do not ask any clarification.
2. Make sure to switch off your mobile phones before the Exam starts.
3. No USB’s are allowed. Please see that the area in your threshold is clean. You will be charged for any
material which can be classified as ‘helping in the paper’ found near you.
4. Talking/Discussion is not allowed. It is your responsibility to protect your code and save it from being
copied. If you don’t protect it all matching codes are considered copy/cheating cases.
5. You are not allowed to use internet for any purpose.
-------------------------------------------------------------------------------------------------------------------------------
Q # 1. Write relevant code in order to support compilation and execution of the given main (10 points)

FOR All SECTIONS except G FOR SECTION G Only


int main() int main()
{ {
KeyValue<int, double> floor (4,4.45); KeyValue floor; Cin>>floor;
KeyValue<int, double> ceiling (5,4.55); KeyValue ceiling; Cin>>ceiling
Cout<<floor<<endl; //key = 4, value = 4.45 Cout<<floor<<endl; //key = 4, value = 4.45
Cout<<ceiling<<endl; //key = 5, value = 4.55 Cout<<ceiling<<endl; //key = 5, value = 4.55
} }

Q # 2. (For All Sections) (40 points)


Part-1:
Let’s say there is a Nehari shop named WarisNehari. The owner is facing a problem for too
many orders for Nehari from online booking and as a cutting-edge, the owner of WarisNehari
might end up writing some code for his only item Nehari.
Nehari which is made up of following ingredients “Namak, Mirch, Bong, Ghee and Haldi”. As
Lahori people love WarisNehari and they have asked for different varieties of Nehari. So, the
owner has decided to extend Nehari to Nully Nehari, Maghz Nehari and Chicken Nehari. All
these types of Nehari have all above ingredients but they can have more special ingredients
and different method of preparation. When there was only type of Nehari, the price of Nehari
was 140 Rs. per plate. As there are new types introduced, so price varies for every type. You
can assume for 160 Rs. for Nully, 180 Rs. Maghz and 150 Rs. for Chicken Nehari.
Note, for coding perspective:
 Nehari can be a class
 Ingredients can be members. Ingredients is just a two-dimensional array of character
type which can store the names of ingredients.
 Special Ingredients for Nully Nehari are “Nully and Sonth”, for Maghz Nehari are “Maghz
and Sonf” and for Chicken Nehari are “Chicken and Jaifal”. In the constructors of every
Nehari ingredients are added.
 Price is a member as well
To prepare Nehari the owner had hired a person which was preparing Nehari in old times. Now,
the same person prepares sub types of Nehari, but he prepares Nully Nehari, he adds special
ingredients and tells the owner Nully Nehari has been prepared. The same case for all other sub
types of Nehari. For coding, it’s a functionality performed by WarisNehari over its items.
WarisNehari has written a code to print menu online, which prints menu for Nehari with its
subtypes and their prices.
For Coding perspective: To test the above program:

 WarisNehari is also a class which


has menu function and many other void main(){
food items as member. Of which DesiDhaba * desiDhaba = new DesiDhaba();
we are discussing only Nehari, int menuOfNehari = desiDhaba->menu();
whenever some order is placed at if(menuOfNehari==1) desiDhaba.prepare("Nully");
WarisNehari, this is informed that else if(menuOfNehari==2) desiDhaba.prepare("Maghz");
else if(menuOfNehari==3) desiDhaba.prepare("Chicken");
of which type of Nehari customer
else if(menuOfNehari==0) cout<<”No Food item\n”;
wants.
//Do rest of the things
 WarisNehari proceeds/calls to
}
prepare functionality that special
type of Nehari should be prepared).
Part-2:
Now WarisNehari is intended to take orders from customers who are online. So, they will be
needing first to show menu to people.
For Coding perspective:
 Menu is presented to Customer.
 The customer will be given a choice in Nully, Maghz and Chicken Nehari. As the
customer chooses an option and order is placed.
 Finally dhaba calls the delivery function.
As all of them are good programmers, they know if WarisNehari * dhaba = new WarisNehari();
they have taken some memory from heap they int foodOption = dhaba->menu();
return before they go to sleep. And they keep track dhaba .order(foodOption);
that either we had children or not, so they could /*Inside order function of WarisNehari you can write this
make sure who should sleep first and do his if( option ==1) dhaba.prepare("Nully");
responsibility later. else if(option==2) dhaba.prepare("Maghz"); //and so on
*/
You are requested to identify the classes, their dhaba->deliver(foodOption); //Do rest of the things
data members, member functions and virtual }
behavior (if there is need of). You can’t change
the name of classes. Please write main to test
your “KhanaShana” pass the relative variables
to functions.

You might also like