Вы находитесь на странице: 1из 3

OOP Assignment No 1

Dead Line: 16-10-2019 Course Instructor: Idrees Ahmad

Instructions:
a) Copied assignments will be awarded zero marks.
b) Late submission will not be acceptable.
c) Submit assignments in the form of hard copy.
(Structures related)
Q# 1) Write a program to help a local restaurant automate its breakfast billing system. The program
should do the following:
a) Show the customer the different breakfast items offered by the restaurant.
b) Allow the customer to select more than one item from the menu.
c) Calculate and print the bill.
Assume that the restaurant offers the following breakfast items (the price of each item is shown to the
right of the item):
Plain Egg $1.45
Bacon and Egg $2.45
Muffin $0.99
French Toast $1.99
Fruit Basket $2.49
Cereal $0.69
Coffbee $0.50
Tea $0.75
Use an array, menuList, of the struct menuItemType. Your program must contain at least the following
functions:
• Function getData: This function loads the data into the array menuList.
• Function showMenu: This function shows the different items offered by the restaurant and tells the user
how to select the items.
Function printCheck: This function calculates and prints the check.
(Note that the billing amount should include a 5% tax.)
A sample output is:
Welcome to Johnny's Restaurant
Bacon and Egg $2.45
Muffin $0.99
Coffee $0.50
Tax $0.20
Amount Due $4.14
Format your output with two decimal places. The name of each item in the output must be left justified.
You may assume that the user selects only one item of a particular type.

(Classes related)

Q#1). Define a class to represent a complex number called Complex. Provide the following member
functions:-

1. To assign initial values to the Complex object.

2. To display a complex number in a+ib format.

3. To add 2 complex numbers. (the return value should be complex)

4. To subtract 2 complex numbers

Write a main function to test the class.

Q#2). Create a class called Time that has data members to represent hours, minutes and seconds.
Provide the following member functions:-

1. To assign initial values to the Time object.

2. To display a Time object in the form of hh:mm:ss {0 to 24 hours}

3. To add 2 Time objects (the return value should be a Time object)

4. To subtract 2 Time objects (the return value should be a Time object)

5. To compare 2 time objects and to determine if they are equal or if the first is greater or smaller than
the second one.

Q#3)a. Define a class named Movie. Include private fields for the title, year, and name of the director.
Include three public functions with the prototypes
void Movie::setTitle(string);

void Movie::setYear(int);

void Movie::setDirector(string);

Include another function that displays all the information about a Movie.

Q#3)b. Include a function which accepts 2 objects of type Movie and displays whether or not they were
released in the same year and also whether the Directors are same. String functions may be used.

Q#4). Create a class called Stack for storing integers. The data members are an integer array for storing
the integers and an integer for storing the top of stack (tos). Include member functions for initializing tos
to 0, pushing an element to the stack and for popping an element from the stack. The push() function
should check for “stack overflow” and pop() should check for “stack underflow”.

Оценить