A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a program that will calculate and print the parking charges for each of 3 customers who parked their cars in this garage yesterday. You should enter the hours parked for each customer. Your program should print the results in a neat tabular format and should calculate and print the total of yesterday's receipts. The program should use the function calculateCharges to determine the charge for each customer.
Write a c++ program using function that take an array of integers as input and return the
sum of number in the array.
Identify an error in the following pseudocode: (2)
sum = 0
for x = 1 to 10
if y MOD 2 = 0
display y
sum = sum + y
Melokuhle is a very young intelligent and adventurous individual. He has recently
bought 4 quantums (taxi) to transport people around the country. As a result, he is
planning a trip to Upington.
Therefore, he has hired you to write a program in pseudocode as well as in C++ to
evaluate the fuel consumption on his 4 cars during the planned trip. The kilometers
and fuel level in the tank at the start and end of the journey should be entered by the
end-user.
Calculate for each car, the fuel used, kilometers traveled, and the overall fuel
consumption in kilometers traveled per litre of fuel
Rewrite the following for-loop as a post-test do-loop. (5)
for x = 20 to -20 step -3
display "x = ", x
next x
Rewrite the following for-loop as a pre-test while-loop. (6)
for x = 1 to 10
for y = 10 to x
if y MOD 2 = 0 then
display "*"
else
display "#"
endif
display " " ~newline
Determine the exact output that is produced when the following code is executed.
for x = 1 to 10 step 1
for y = 1 to x step 1
if y MOD 2 = 0 AND x MOD 2 <> 0 || y MOD 2 <> 0 AND x MOD 2 = 0 then
display "*"
else
display "#"
endif
next y
display " " ~newline
next x
Input:
staff name, the amount of loan, Year of Installment = 2 Process:
Do the decision
if (amount of loan < 5 000)
interest = 2
else if ( 10 000 < amount of loan >= 5 000)
interest = 2.5 else
Display “Invalid input. The maximum amount is RM10000”
interest = 0 Calculate Total of Interest
= (interest/100) * amount of loan
Calculate the Total Loan with Interest = amount of loan + Total of Interest
Calculate the monthly installment
= Total Loan with Interest / (Year of Installment * 12)
Output:
staff name, the amount of loan, monthly installment.
Write a program that takes an array ‘A’ of size 10 and an integer ‘x’ as input and searches the index of ‘x’ in the array. If ‘x’ is found, print the index. If ‘x’ is not found, then print -1. If ‘x’ is present two or more than two times in the array, then print the index of last occurrence of ‘x’.
The FizzBuzz Game
by CodeChum Admin
Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with rules of math applied since math is fun, right? Just print out "Fizz" when the given number is divisible by 3, "Buzz" when it's divisible by 5, and "FizzBuzz" when it's divisible by both 3 and 5!
Let the game begin!
Input
A line containing an integer.
15
Output
A line containing a string.
FizzBuzz