A concert hall has three seating categories: VVIP, VIP and GEN. Customers are allowed to book tickets to
attend any concerts that will be hosted in that hall using the price category as listed in Table 1. The
customers can book a minimum of 1 and a maximum of 10 tickets per category.
The manager wants a program that will allow him to sell tickets to the public and to calculate the revenue
he will get from selling the tickets in a day.
Table1:
Ticket Category Price Catergory
VVIP R3054.61
VIP R2095.51
GEN R1077.30
3.1 Create a C++ source file called TicketSales and save it in a file called TicketSales.cpp.
3.2 Create the following functions:
Functions:
Function Description Marks
3.2.1 validateInput() This function will receive two parameters that will consists of
the number of tickets and ticket category respectively.
This function must then determine and return results if the
number of tickets entered is valid as well as the catergory.
8
3.2.2 determineTicketPrice() This function will receive one parameter that will consists of
the ticket category.
The function must then determine and return the price for that
particular catergory using the information above
3.2.3 determineConcertPrice() This function will receive two parameters that will consists of
the number of tickets as well as the ticket price respectively.
This function must then calculate and return the amount due
for the concert. This amount must be inclusive of 15% vate
rate.
3
3.2.4 main() Add necessary pre-processor directives.
NB: The functions must be implemented above the main.
Declare all necessary constants and variables.
Prompt the user for the number of tickets he/she is
buying or a zero (0) to exit program.
Fill in the blanks in the following code. The code is written to draw 4 rectangles of heights 20, 30, 40, 50 respectively and widths 20, 15, 10, 5 respectively. The centres of these rectangles are at (1,2)
initCanvas();
double x=20;
double y=20;
repeat(4){
Rectangle r( BLANK-P , BLANK-Q , x, y);
r.imprint();
x = x + BLANK-R ;
y = y + BLANK-S ;
}
To do list
This project will record an event which will be described by Title, Description, Date, Time. The events will be stored and retrieved from a text file called events.txt. The program should read a file at a start and should store and delete new and already present events from text file. This program should find events with respect to date as well as name. All search event description should be displayed.
When should you consider using recursive algorithms when writing a program?
Discuss in terms of advantages and disadvantages
A variable used to send information to a function is called a ___________.
1. Write the exact output of the following algorithms:
1.1. Function calcValues(valX, valY)
return (valX + valY/2)
JustValues
a = 14
b = 5
totResults = 0
for x = 1 to 5 step 3
results = calcValues(a, b)
totResults = totResults + results
next x
display “The result is” , totResult
display “The result is” , x
1.2 Function calculate (valX, valY)
answer = valX + valY
return answer
JustCalculations
a = 14
b = 5
do while a < 5
r = calculate(a, b)
b = a + 5
a = a + 1
display “a =” , a, “b =” , b, “r=” , r
loop
end
1.3.1 sub calcProc (valA, refB)
value = valA * 3
refB = value - refB
End sub
Function calcFunc (valK)
return ((valK * 2) MOD 4)
MainModule
M = 4
L = 1
K = 2
do
J = CalcFunc (M)
Call CalcProc (J, K)
Display “L = “ L, “J = “ J, “K = “ K, “M = “ M
M = M + 1
Loop Until M > 5
end
4.1.1 Students in Computer Science would like to understand the concept of Ohm’s law. You
are required to write an application that will allow them to calculate the relation
between Voltage, Current and Resistance using the formulas below.
V = IR
Current (I) = V/R
Resistance= V/I
(where I is the current, V - Voltage and R is the resistance)
4.1.1 Write a program that will assist the students:
4.1.2 Create a C++ source file called OLaw and save it in a file called OLaw.cpp.
4.2 Create the following functions:
4.2.1 calcVoltage() This function must calculate the voltage in a circuit using the
information given above.
4.2.2 calcCurrent() This function must calculate the current charge using the information
given above.
4.2.3 calcResistance() This function must calculate the resistance of the flow using the
information given above.
4.2.4 main() NB: The functions must be implemented above the main.
Add all necessary pre-processor directives.
Declare all constants and necessary variables.
Prompt the user for the calculation he/she would like to see
(I/I, V/v, R/r)(See Figure 4.1).
Based on the option selected by the user
o The user must be prompted for the related data as
shown in Figure 4.2 – Figure 4.4.
o The program must then calculate the related
measurements based on the option by calling the
correct function.
o Display the desired measurement.
If an invalid option is selected an appropriate error message
must be displayed, see Figure 4.5.
NB: Use a switch for the selection
o This process must be repeated until there no calculations to
perform (N/n).
4.3 Rewrite 4.2 as follows:
4.3.1 Create a C++ source file called OLaw2 and save it in a file called OLaw2.cpp.
4.4 Create the following functions:
4.3.1 calcCicuirt() This function must calculate the voltage, current and the resistance
in a circuit using the information given above.
4.3.2 getInput() This function will prompt the user for the required input as indicated
in Figure 4.1.
4.3.3 main() NB: The functions must be implemented below the main.
Add all necessary pre-processor directives.
Declare all constants and necessary variables.
Prompt the user for the input values by calling the correct
function.
The program must then calculate the required
measurements by calling the correct function.
Write a function which converts an uppercase letter 'A'{'Z' to the corresponding lowercase
letter. If the parameter is not a letter it must be returned unchanged. Write a main program
which calls the function.
Write a program with a function that takes two int parameters, adds them together, then
returns the sum. The program should ask the user for two numbers, then call the function
with the numbers as arguments, and tell the user the sum.
Write a function named times Ten . The function should have an integer parameter named
number. When times Ten is called, it should display the product of number times ten. (Note:
just write the function. Do not write a complete program.)