Week 7

7th Week (7th April 2013)

Hey dear readers, it’s the holidaaaaaays!! For mid-sem!! Yaaaayyy! Updating from my hometown Miri, I bring you news that we had our written test a few days before the holiday started. I don’t have the question paper with me but I do remember that the last question required me to write a full functional program to calculate the parking fee according to the type of vehicles parked there….. by there, I mean, I don’t know where. The thing is, I decided to blog about this since I don’t have anything else to post and that I was curious about my written program. I rewrote the program by memory into the IDE and gave it the usual test-run. Well, it works for me. So here’s my program. It may not answer the question in the first since I may have misinterpreted it in the first place….. Well, let’s just enjoy my fail.

#include <cstdlib>

#include <iostream>

/* Name : Nur Arina Bt Faizal   Matric No : UK25837  Date :  7th April 2013

Written Exam

Program : Program to Calculate Parking Fee According To Types of Vehicles

PROBLEM: Parking Fee According To Types of Vehicles


Types of Vehicles and Payments

Type A – Lorry          RM 50.00

Type B – Fancy Cars     RM 30.00

Type C – Okay Cars      RM 10.00

Type D – Motorcycle     RM  1.00

Sample Data;

A    A    B    X    C

Note : Make sure that any wrong input data will not cause any error in the outcome.

(A) Algorithm

Input    : The input data is the number of vehicles corresponding to the type of vehicle;

nA for Type A, nB for Type B, nC for Type C and nD for Type D.

Process  : Calculate the payment;

a) Multiply the number of vehicle to its corresponding value designated for its type.

A = 50, B = 30, C = 10, D = 1

p1 = nA * A

p2 = nB * B

p3 = nC * C

p4 = nD * D

b) Add all the payments to get the total charge;

tp = p1 + p2 + p3 + p4

Output   : The results that need to be displayed are;

a) Number of vehicles of each type.

b) Total charge of parking.  */

using namespace std;

void getData(); // Divide and conquer strategy using 3 functions

void calcData();

void dispData();

int main(int argc, char *argv[])


int loop, N;

// Introduction to program

cout << “\n********* Written Test Aaarrrrrrrrgggghhhh **************” << endl;

cout << ”   * Program to Calculate Parking According to the Type of Vehicle *” << endl;

cout << ”  **** Name : Aaaaaaaaaaaaarrrrrrggggghhhhhh *******” << endl;

cout << ”   ********  Matric No : UK IDONTCAAARREEE ***********” << endl << endl << endl;

getData();   // Call function 1

calcData();  // Call function 2

dispData();  // Call function 3

cout << “\nEnd of Thing” << endl;




void getData()


float nA, nB, nC, nD, A, B, C, D;

// First ‘user prompt’

cout << “\nPlease input the number of vehicles for: ” << endl;

cout << “\nType A Lorry: ” << endl;

cin >> nA;

cout << “\nType B Fancy Cars: ” << endl;

cin >> nB;

cout << “\nType C Okay Cars: ” << endl;

cin >> nC;

cout << “\nType D Motorcycles: ” << endl;

cin >> nD;


void calcData()


float  nA, nB, nC, nD, A, B, C, D, p1, p2, p3, p4, tp;

A = 50;

B = 30;

C = 10;

D = 1;

p1 = nA * A;

p2 = nB * B;

p3 = nC * C;

p4 = nD * D;

tp = p1 + p2 + p3 + p4;


void dispData()


float  nA, nB, nC, nD, A, B, C, D, p1, p2, p3, p4, tp;

cout << “\nThe payment for lorries is: ” << p1 << endl;

cout << “\nThe payment for fancy cars is: ” << p2 << endl;

cout << “\nThe payment for okay cars is: ” << p3 << endl;

cout << “\nThe payment for motorcycles is: ” << p4 << endl;

cout << “\nThe total payment is: ” << tp << endl;


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s