Vous êtes sur la page 1sur 3

ITC

Assignment Mark: 10
1. A restaurant wants to automate their reservation process. They need a program that reads the service
package and the count of people from the console and calculates how much the customer should pay to
book the place.
Different halls have different prices:
Small Hall Terrace Great Hall
Price 2500$ 5000$ 7500$
Capacity 50 100 120
The restaurant has discounts depending on the service package, which the group wants.
You can see the discounts on different service packages in the table below:
Normal Gold Platinum
Discount 5% 10% 15%
Price 500$ 750$ 1000$
You should add the price of the package to the price of the hall. The discount is calculated based on the
hall’s price + package’s price.
Example: The group has 10 people and wants the gold package  $292.50 per person.

Requirement of arrays
• You are required to generate a 2D array of size 2X3 for hall which will be consisted of price and
capacity.
• You are required to generate a 2D array for package of size 3X3, where first row should contain
package number such as 1 for normal 2 for gold and so on, 2nd row for discount and 3rd row for
price.
• You are required to generate an array to pointer consisting of the hall type’s i.e., small hall,
terrace etc.
• You are required to generate an array to pointer, which will have the package name i.e., normal,
gold etc.
Your program should have the following functions:
1). An input() function which is called from main, which accepts nothing as an argument and return
nothing.
2) A Capacity () function will accept the total number of guests. Your function must be consisted of 2D
array where every row will represent the price of each hall placed in different columns. Your function
must return the price against the number of guest using the 2D array to the input().
3) A package () which will accept package name in the form of number i.e., 1, 2 or 3 and will return the
package price as well as the discounted price retrieved from 2D array of package to the input().
4) A totalPrice () will accept the hall price + the package price and will return the total price after
discount to the input().
5) A priceperperson() will accept the total price and will return the price per person to the input().
6) A print() which will accept the number of guest, the hall price, package price and price per person and
will print the final output as mentioned in the figure below:
Note: You may change the return type according to your assumption.

2. Blood types are important for blood transfusion.


The following table summarizes blood groups compatibility:

Donor
Recipient O- O+ A- A+ B- B+ AB- AB+

O- 1 0 0 0 0 0 0 0
O+ 1 1 0 0 0 0 0 0

A- 1 0 1 0 0 0 0 0

A+ 1 1 1 1 0 0 0 0

B- 1 0 0 0 1 0 0 0

B+ 1 1 0 0 1 1 0 0

AB- 1 0 1 0 1 0 1 0

AB+ 1 1 1 1 1 1 1 1
Write a program that helps the user to clarify blood compatibility issues.
Your program must consist of a function named bloodChecking(), which will accept the above stored
matrix i.e. 0, 1 and blood names i.e., O+ etc.
Hint:
• “1” means you can receive or donate blood to specific blood groups and 0 means you cannot
receive or denote blood to specific blood group.
• You have to design 2D arrays for above mentioned [8X8] matrix
• You have to design an array to pointer for storing blood names i.e., O-, O+ etc.
• See the output carefully for understanding the donation and receiving process.
3. A word is considered elfish if it contains the letters: e, l, and f in it, in any order. For example, we
would say that the following words are elfish: whiteleaf, tasteful, unfriendly, and waffles, because they
each contain those letters.
• Write a recursive function called elfish, that, given a word, tells us if that word is elfish or not. Your
recursive function must return the location of elfish word in user entered string.
4. Write a recursive function called x-ish? That, given two words, returns true to the main() if all the
letters of the first word are contained in the second word.

5. Write two recursive function named input() and minimum(). Your input() function must take the input
in an array recursively and return the array to the main(). Your minimum() must accept the array as an
argument and returns the minimum number stored in an array. Thinking recursively, the minimum is
either the first value in the array or the minimum of the rest of the array, whichever is smaller. If the list
only has 1 integer, then its minimum is this single value, naturally.

6. Generate the sequence. The sequence starts at a positive integer n and is generated by following two
simple rules. If n is even, the next number in the sequence is n/2. If n is odd, the next number in the
sequence is 3*n+1. Repeating this process, we generate the sequence. Write a recursive function names as
hailstone() with void return type which prints the sequence. Stop when the sequence reaches the
number 1.(You may take arguments in the function according to your requirement).
For e.g. n=10 the sequence will be 1, 2, 4, 8, 16, 5, 10.
7. Multiply any 2 numbers.
Your multiplication must be similar to as if done by hand. Given 2 integers, you must show all partial
products generated as a result. (You may make assumption according to your requirement).
eg: 1035 (output format is critical)
12
-----
2070
1035X
------
12420

8. Moving Zeros to the end in 2-D array.


Design a function which will move all 0’s of 2D to the end of an array.
Print the changed array from the main ().

9. Design Question No.8 using “pointer to an array” with same functions parameters. This time your
function must not change the original array.

Vous aimerez peut-être aussi