Assignment 5 - UiTM Pahang

advertisement
Page 1
ASSIGNMENT 5 (REPETITION CONTROL STRUCTURE)
CSC425: INTRODUCTION TO COMPUTER PROGRAMMING
Question
Your program will asks you to enter any numbers. It will continue to ask for a number until you
choose no. there are no limitation on how many numbers you can enter. After you choose no, the
program will identify how many numbers have you entered, how many even numbers have you
entered, how many odd numbers have you entered, the sum of all the numbers you have entered,
and the average of the numbers you have entered.
a. Identify the output, input and process for the above problems using CoPS Method (kindly
refers to page 3).
b. Using the specification gathered in (a), draw flowchart to illustrate the algorithm of getting
the inputs, processes and producing the outputs.
c. Write a C++ program. Make sure you are using an appropriate data type for each variable
you used.
(Example of program execution)
Page 2
YOU ARE REQUIRED TO:
d. Identify the output, input and process for the above problems using CoPS Method (refer to
the next page).
e. Using the specification obtained in (a), draw flowchart to illustrate the algorithm of getting
the inputs, processes and producing the outputs.
f. Write a C++ program based on (b).
CoPSMETHOD
Example: If you are given the radius of one circle, you can calculate the area of that circle. Write a
complete C++ program to calculate and display the area of the circle. Assume the value of is 3.142.
Output
Output variables:
area
Input
Input variables:
radius
Process
Processing items:
area
Formulae:
area = PI * radius * radius
Constants:
PI = 3.142
Steps / Solution algorithm:
1. Get input (from keyboard)
Read radius
2. Calculate area (in CPU and Memory)
area = PI * radius * radius
3. Display output (to screen console)
Print area
Instruction to the students (Please read carefully and thoroughly):
You are required to submit your program in hardcopy format only. You are also required to
demonstrate the execution of your program to your lecturer for approval before the submission,
and the output of the program must be printed out and attached together during submission.
The Scoring Rubric for marking scheme must be attached together during submission of your
assignment; otherwise NO marks will be given for your assignment.
Deadline is on December 13th, 2012, 5:00 PM. Late submission and plagiarism will be
penalized and marks will be deducted.
Page 3
ASSIGNMENT 5 (REPETITION CONTROL STRUCTURE)
CSC425 : INTRODUCTION TO COMPUTER PROGRAMMING
20
Scoring Rubric
Student ID
: ________________________________________________________________
Name
: ______________________________________________________________
Group
: ______________________________________________________________
Marking Scheme
Category
Problem analysis, precision
and clarity of flowchart /
pseudocode
Clarity of program’s
presentation
Structure and algorithm of
a program
Important required
variables for input, process
and output
Result
Weak
1
Remarks
Moderate
2
Good
Very Good
3
4
Output, input and process is correctly identified.
Flowchart or pseudocode is correctly drawn and written.
1
2
3
4
The program is clearly written as well as easy to understand.
Each of the process is documented.
1
2
3
4
The algorithm of the program is capable of solving the
problem completely. There is no syntax error, logic error
and run-time error.
1
2
3
4
All input, process and output variables are clearly defined
and outlined
1
2
3
4
The program produced expected output with correct and
presentable format.
Download