You are on page 1of 2

QUIZ 1

TOPIC: Basic Elements of Computer Program

Name:
ID
GROUP:

1. Write C++ statement(s) to do the following tasks:


a. Declare a constant called TAX_RATE and initialize it to 0.03.
(1 mark)

b. Declare three integer variables, prompt for user to enter three numbers and
read the numbers.
(2 marks)

c. Initialize integer variables A to 1 and power to 1.


(1 mark)

2. What type of error when your code violates one or more of the grammar rules of
programming language?
(1 mark)

3. Suppose x, y and z are int variables and w and t are double variables. What value
is assigned to each of these variables after the last statement executes?

Let x = 17, y = 15;


(3 marks)
a. z = x % 3 + 4.6
b. w = y / 3 + 6
c. t = x / 4.0 + y % 4 – 3.5

4. Write a C++ assignment statement for each of the following:


(6 marks)
i ````

iii
5. ABC Private Parking is charging each customer a parking fee based on the number
of hours they park their vehicles. It is charge RM2 for the first 1 hour and RM1 per
hour for subsequent hours. Write a program to calculate the parking payment for a
customer. The program will prompt the customer to enter the car registration number,
date, and parking hours.

All the data entered will be displayed together with the parking fee as in the example
receipt:

ABC PRIVATE PARKING


CAR NUMBER: DDN1234
DATE: 2/10/2019
PARKING HOUR: 3
TOTAL PAYMENT: RM 4
THANK YOU FOR USING OUR SERVICE
(6 marks)

You might also like