Download Assignment 1 - Programming - Distinction and more Assignments Computer Science in PDF only on Docsity!
ASSIGNMENT 1 FRONT SHEET
Qualification BTEC Level 5 HND Diploma in Computing
Unit number and title Unit 1: Programming
Submission date 21/12/2021 Date Received 1st submission
Re-submission Date Date Received 2nd submission
Student Name Huynh Minh Huy Student ID GCD
Class GCD1001 Assessor name Do Duy Thao
Student declaration
I certify that the assignment submission is entirely my own work and I fully understand the consequences of plagiarism. I understand
that making a false declaration is a form of malpractice.
Student’s signature Huy
Grading grid
P1 M1 D
❒ Summative Feedback: ❒ Resubmission Feedback:
Grade: Assessor Signature: Date:
Lecturer Signature:
- Scenario
- CHAPTER 1: State your simple business problem to be solved.
- Definition
- 1.1. What is Algorithm?
- 1.2. Characteristics of Algorithm.
- Example of Algorithm.
- 2.1. Sorting Algorithm.
- 2.2. Represent a small, simple problem and solve this problem.
- CHAPTER 2: Analyse the problem and design the solutions by the use of suitable methods.
- Analyze the problem.
- Flowchart.
- CHAPTER 3: Demonstrate the compilation and running of a program.
- Introduce how the problem is solved.
- Soure code and screenshots of the final result.
- 2.1. Function input two real numbers a and b.
- 2.2. Function find the solution x.
- Explain briefly what is Software Development Life Cycle.
- 3.1. What is Software Development Life Cycle?
- Explain how the source code is compiled.
- 4.1. The programming process.
- 4.2. Compiled languages.
- by a specific programming language. CHAPTER 4: Evaluate how the problem is solved from the designed algorithm to the execution program written
- Test case.
- a. Case 1: PASSED.
- b. Case 2: PASSED.
- c. Case 3: PASSED.
- d. Case 4: FAILED.
- specific programming language. 2. Evaluate how the problem is solved from the designed algorithm to the execution program written by a
- References
- Figure 1: Bubble sort. Table of Figures
- Figure 2: Simple Equation Flowchart.............................................................................................................................
- Figure 3: Input a and b...................................................................................................................................................
- Figure 4: Find the solution x.
- Figure 5: Stages of the Software Development Life Cycle.
- Figure 6: How the source code is compiled.
- Figure 7: Case 1.
- Figure 8: Case 2.
- Figure 9: Case 3.
- Figure 10: Case 4.
Scenario
You have applied for a post as a trainee with a software development company and have been
invited for an interview. You have been asked to demonstrate your problem solving and basic
programming skills. To do this you have to prepare a report on using algorithms to solve problems.
You need to explain, using examples, how algorithms are used to solve simple business problems
and the steps needed to be followed to produce a working program solution. You should make clear
your assumption about your program. The problems to be solved will involve basic procedural
programming instructions - sequence instructions (input, output and assignment statements),
loops, conditional statements. Problems should be analysed and designed by the use of flowchart
and demonstrated by the use of modules (procedures).
Feasible: The method must be basic, general, and practical enough to be run with
the given resources. It must not include any futuristic technologies or anything else.
Language Independent: The planned algorithm must be language-independent, i.e.
it must be merely simple instructions that may be implemented in any language and
still provide the intended results.
2. Example of Algorithm.
2.1. Sorting Algorithm.
One of the most efficient sorting algorithms is Bubble Sort. Bubble Sort is the most basic
sorting algorithm, and it operates by periodically exchanging nearby components if they are
out of order.
Figure 2 : Bubble sort.
Example:
First Pass:
(5;1;4;2;8) - > (1;5;4;2;8), In this case, the algorithm compares the first two items
and swaps them since 5 > 1.
(1;5;4;2;8) - > (1;4;5;2;8), Swap since 5>4.
(1;4;5;2;8) - > (1;4;2;5;8), Swap since 5>2.
(1;4;2;5;8) - > (1;4;2;5;8), Because these items are already in the correct order (8 >
5), the algorithm does not swap them.
Second Pass:
(1;4;2;5;8) - > (1;2;4;5;8), Swap since 4>2.
The array is already sorted, but the algorithm isn't sure if it's finished. To know if
the algorithm is sorted, it requires only one complete pass with no swaps.
Third Pass:
2.2. Represent a small, simple problem and solve this problem.
I have a simple equation ( ax + b= 0 ) and two coefficient a and b which is 2 for a and 3 for b. I
do not know how to find x so in this problem I will utilize an algorithm to solve this problem.
CHAPTER 3: Demonstrate the compilation and running of a program.
1. Introduce how the problem is solved.
I built a basic program that works with simple equations, so now I will enter two coefficients a = 2
and b = 3 into the program, and the program will assist me in solving the issue and returning the
proper result.
2. Soure code and screenshots of the final result.
2.1. Function input two real numbers a and b.
Figure 4 : Input a and b.
In this part, I have declared float variable for a, b and x. After I finished declaring, I made a
function to input numbers a and b and convert a and b to float.
2.2. Function find the solution x.
After entering 2 numbers a and b, the program will check the numbers that I have entered. If a = 0
and b # 0, the program will report the equation has no solution. Additionally, if a = 0 and b = 0, then
the program will report the equation has infinitely many solutions. Finally, if a ≠ 0, then x = - b/a
declares the equation has only solution x and then ends.
Figure 5 : Find the solution x.
As stated in the introduction, the SDLC consists of six phases. The waterfall model, spiral
model, and Agile model are all popular SDLC models.
4. Explain how the source code is compiled.
4.1. The programming process.
Human languages are not understood by computers. In truth, computers only interpret
sequences of numbers that represent operating codes at the most basic level (op codes for
short). Humans, on the other hand, would find it extremely difficult to develop programs in
terms of op codes. As a result, programming languages were developed to let people create
computer programs more easily.
Humans read and comprehend programming languages. The program (source code) must
be translated into machine language before it can be executed by the computer (as the
computer only understands machine language). The manner in which this translation occurs
is determined by whether the programming language is compiled or interpreted.
4.2. Compiled languages.
The process of programming in a compiled programming language is depicted in the
diagram below.
Figure 7 : How the source code is compiled.
A compiler translates source code into machine language modules (called an object file). A
linker links this object file with other previously built object files (in particular run-time
modules) to generate an executable file.
c. Case 3: PASSED.
Expected test:
Input: a = 0 ; b = 5. Output: The equation has no solutions.
Actual test:
Figure 10 : Case 3.
d. Case 4: FAILED.
Expected test:
Input: a = e. Output: Invalid, please enter again.
Actual test:
Figure 11 : Case 4.
2. Evaluate how the problem is solved from the designed algorithm to the execution program written by
a specific programming language.
Algorithms truly aid in the development of a habit that I never contemplate, that produces a solid
plan of step-by-step solutions that may progressively actualize coding ideas. Drawing schedules
also assists in the development of problem-solving theories, such as flowcharts. All of this enables
me to code the software in a more fluid manner.
Although the algorithms aids me greatly in coding, but I am still unsatisfied with the programabove
since it lacks a section where, if the user types an error, it would display an error message and
prompt the user to re enter.
This will be included to my résumé, and I will continue to upgrade these functions in the future.