Anda di halaman 1dari 4

TSE1363 : FUNDAMENTALS OF PROGRAMMING

ASSIGNMENT 2
1. Instruction: Answer all questions
QUESTION 1: Limitless Parking
Many carparks today still operate based on the duration you park your car.The
longer you park, the more you have to pay!Write a C++ program to calculate the
total charge incurred while using a carpark. Assume that you can park in the
carpark for a maximum of 1,000 hours.
The program should prompt the user to enter the parking duration in hours, and
the total carpark charge will be displayed. The following table shows the

charge

plan for this carpark:


******************************************************************
Duration

Charge (RM)

----------------------------------------------------------------------------First 3 hours

2.00

The next 2 hours

3.00

Following hours thereafter

2.50

******************************************************************
The following sample runs demonstrate the required format of display and some
possibleinput.
SampleRun1:
Parkingduration(hrs):1
Totalcarparkcharge:RM2.00

SampleRun2:
Parkingduration(hrs):3.5
Totalcarparkcharge:RM5.00

SampleRun3:
Parkingduration(hrs):6
Totalcarparkcharge:RM7.50
Jan June 2015

Page 1

TSE1363 : FUNDAMENTALS OF PROGRAMMING

Write a program that calculates a customers parking charge. It should ask the
user to enter number of hoursthe customer has parked . It should then display
the total carparkcharges for the customer.
QUESTION 2: Separate numbers by sign, compute sums and averages of
the numbers
Write a program that asks the user for ten numbers which consist of positive
and negative nonzero integer values. The program should use a loop to compute
the sum and average of all positive integers , the sum of and average of negative
numbers and the sum and average of all the number entered.
Sample run:
Enter ten numbers, I'll echo your number and compute
the sum and average of positive numbers
the sum and average of nonpositive numbers
the sum and average of all numbers
4
value 4
5
value 5
-1
value -1
3
value 3
-4
value -4
-3
value -3
9
value 9
8
value 8
7
value 7
2
value 2
Sum of Positive numbers is 38
Average of Positive numbers is 5.42857
Sum of NonPositive numbers is -8
Average of NonPositive numbers is -2.66667
Sum 30
Average is 3
Press any key to continue
Jan June 2015

Page 2

TSE1363 : FUNDAMENTALS OF PROGRAMMING

2. What To submit?
1. A printed report containing the following sections
i.
ii.
iii.

Cover Page: must have the names and IDs of group


members, and tutorial section
Problem statement : the question
System Design
a. Pseudo code
b. Flowchart

2. Source code :C++ programs


a. Each source code must refer to the previous pseudo code and
flowchart to develop program in the system design
3. Screen shots showing sample run of your programs
3. The Marking Scheme
Your submission will be evaluated according to this scheme:
1. Report submitted before due date.
2. 0 marks for those who plagiarised from others.
3. 0 marks for those who let others copy from their work.
4. Good pseudocode (5 marks)
5. Good Flowchart ( 5 marks)
6. C++ implementation that solves the problem (5 marks)

Jan June 2015

Page 3

TSE1363 : FUNDAMENTALS OF PROGRAMMING

Date of submission: 17 April 2015

Jan June 2015

Page 4

Anda mungkin juga menyukai