Subject Code and Name | PRG1002 Programming 1 |
Assessment Number | 2 |
Assessment Title | Simple Programming Application |
Assessment Type | Individual - Application Code |
Length or Duration | Four (4) Programs / Tasks |
Weighting | 25% |
Assessment Purpose
Many common problems solved by programmers include manipulation of numeric values and lists of numbers. In this assessment, you will use your understanding of the fundamental programming principles to solve four problems that involve numbers.
Assessment Item
For this assessment, you must submit four (4) algorithm descriptions and C++ programs, one for each task described in the brief below
Assessment Instructions
This assessment consists of four (4) tasks. You will need to prepare the following two components for each task.
Component 1: Algorithms
An algorithm is a set of well-defined instructions in sequence to solve the problem. An algorithm should not be computer code. Instead, the algorithm should be written in such a way that it can be used in similar programming languages to implement a solution in code.
Example: Find the largest of two numbers entered by the user.
Step 1: Start
Step 2: Declare variables a and b
Step 3: Get input from the user for a and b Step 4: if a is greater than b
Step 4.1: print a Step 5: if b is greater than a
Step 5.1: print b Step 6: Stop
Component 2: C++ Coding
You will provide a C++ program for each of the four (4) questions given below that implements the algorithm you describe in Part 1.
Assessment Tasks
Task 1 - Grading System
Write a program that allows the user to enter the mark scored within a range of 0 - 50. Given a positive value, do the following:
F, if the percentage is 0 - 59.99. D, if the percentage is 60 - 69.99. C, if the percentage is 70 - 79.99. B, if the percentage is 80 - 89.99. A, if the percentage is 90 - 100.
Example 1
Please enter your score: 32.6
You have passed with 65.2%, and received a grade D.
Example 2
Please enter your score: 10.5
You have failed with 21%, and received a grade F.
Example 3
Please enter your score: 50
You have passed with 100%, and received a grade A.
Example 4
Please enter your score: 74
Score is greater than 50.
Note: Inputs from the user are shown in bold blue. Task 2 - Calculate Miles per Gallon
Write a program that allows a user to enter the litres of petrol consumed and the number of miles travelled by the car. Given a positive value for both litres of petrol and miles travelled, calculate the number of miles per gallon the car delivered. One litre of petrol is 0.264179 gallons.
You must show the output in three decimal places as shown in the example.
Example
Please enter the number of litres of petrol consumed: 15.5
Please enter the number of miles travelled: 75
Petrol Consumed: 15.500
Miles Travelled: 75.000 Miles per gallon: 18.316
Note: Inputs entered by the user are shown in bold blue. Task 3 - Looping Through all Numbers from Start to Finish
Write a program that prompts the user to input two (2) integer values; a starting value and an end value. Loop through all the values from start to end, which should include the start and end values. For each value:
Example
Please enter a start value: 4
Please enter an end value: 15
tock tick 7
8
tick tock 11
tick 13
14
ticktock
Note: Inputs entered by the user are shown in bold blue. Task 4 - Order Numbers
Write a program that prompts the user to input 3 integer values and print these values in ascending and
descending order.
Example
Please enter the first number: 45 Please enter the second number: 12 Please enter the third number: 78
Ascending order:
12
45
78
Descending order:
78
45
12
Note: Inputs entered by the user are shown in bold blue.
For solution, connect with our online professionals.