You are on page 1of 31

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing

Unit number and title Unit 1: Programming

Submission date Date Received 1st submission

Re-submission Date Date Received 2nd submission

Student Name Nguyễn Trọng Phong Student ID BH01180

Class SE06206 Assessor name Ngo Thi Mai Loan

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 phong

Grading grid

P1 M1 D1
 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date:


Lecturer Signature:

1|Page
Contents
A. Introduction ........................................................................................................................................................... 4
B. Contents ................................................................................................................................................................ 5
I. Algorithm ........................................................................................................................................................... 5
1. Definition ...................................................................................................................................................... 5
2. Characteristics of an Algorithm ..................................................................................................................... 6
3. Example for Algorithm................................................................................................................................... 8
II. Steps in program development ....................................................................................................................... 13
III. Solve problems using algorithms ................................................................................................................ 16
1. Math content ............................................................................................................................................... 16
2. Problem analysis.......................................................................................................................................... 16
3. Program Menu............................................................................................................................................. 17
4. Functional analysis ...................................................................................................................................... 18
5. Functions ..................................................................................................................................................... 19
6. Program Execution ...................................................................................................................................... 20
7. Testing and debugging ................................................................................................................................ 25
C. Conclude .............................................................................................................................................................. 29
D. Reference ............................................................................................................................................................ 30

2|Page
Figure I: What is Algorithm? .......................................................................................................................................... 5
Figure II: Characteristics of an Algorithm ...................................................................................................................... 6
Figure III: Eggs and pot .................................................................................................................................................. 8
Figure IV: Boiling eggs.................................................................................................................................................... 9
Figure V: Peel the eggs ................................................................................................................................................ 10
Figure VI: The product is cooked eggs ......................................................................................................................... 11
Figure VII: Quadratic equation solving algorithm ....................................................................................................... 12
Figure VIII: Problem Identification .............................................................................................................................. 13
Figure IX: Planning and Analysis .................................................................................................................................. 14
Figure X: Design ........................................................................................................................................................... 14
Figure XI: Program Menu ............................................................................................................................................ 17
Figure XII: Flowchart program ..................................................................................................................................... 18
Figure XIII: Menu code................................................................................................................................................. 19
Figure XIV: Switch and case and if ............................................................................................................................... 19
Figure XV: When the program is running .................................................................................................................... 20
Figure XVI: When enters 1 ........................................................................................................................................... 21
Figure XVII: Solve first degree equation program. ...................................................................................................... 21
Figure XVIII: When input a and b, result will show ..................................................................................................... 22
Figure XIX: When enters 2 ........................................................................................................................................... 22
Figure XX: Solve quadratic equation program............................................................................................................. 23
Figure XXI: The equation has 2 distinct solution ......................................................................................................... 23
Figure XXII: When the equation has no solution ......................................................................................................... 24
Figure XXIII: When the equation has double solutions ............................................................................................... 25
Figure XXIV: Early stage when coding ......................................................................................................................... 26
Figure XXV: When solve first degreee equation running. ........................................................................................... 26
Figure XXVI: The result is showing when entering a and b ......................................................................................... 27
Figure XXVII: When entering a before ......................................................................................................................... 27
Figure XXVIII: After entering a, b, c and delta, x is showing ........................................................................................ 28

3|Page
A.Introduction

Hi, I’m Trong Phong. I’m a Junior Software Developer studying at BTEC FPT Hanoi Colleges. This is
my Assignment. I had a slight headache about this part of my assignment. It's pretty algorithmic and on
top of that, some of the code kept me awake for a couple of days. But there's no other way, I've wasted a
lot of time on it. And this is the Assignment that I feel is the most perfect I've done. In this asm1 article of
mine, I will present some concepts of algorithms, their characteristics, give examples and its flowchart.
Above all, I will solve some programming problems in C# programming language, analyze them. There are
some concepts as well as some images that I collected and picked up from all over the web around the
world, I don't think it's exhaustive. But anyway, I've been selective about it, and trying to edit it so you can
make it easier to understand. Welcome to my assignment, thanks!!!

4|Page
B. Contents

I. Algorithm

1. Definition

Figure I: What is Algorithm?

What is Algorithm? An algorithm is a step-by-step procedure, or a set of instructions designed to


solve a specific problem or perform a specific task. It is a precise and well-defined sequence of operations
or rules that, when followed correctly, can lead to the desired outcome. In computer science, algorithms
are fundamental to the field of programming and software development. They serve as the building blocks
for creating efficient and effective computer programs. Algorithms can be expressed in various forms, such
as natural language, pseudocode, or specific programming languages. An algorithm could be used for
sorting sets of numbers or for more complicated tasks, like recommending user content on social media.
Algorithms typically start with initial input and instructions that describe a specific computation. When the
computation is executed, the process produces an output.

5|Page
2. Characteristics of an Algorithm

Figure II: Characteristics of an Algorithm

An algorithm is a step-by-step procedure or set of instructions for solving a problem or accomplishing


a task. It is a fundamental concept in computer science and programming. The characteristics of an
algorithm include:

 Well-defined: An algorithm must have clear and unambiguous instructions. Each step should be
precisely specified, leaving no room for ambiguity or interpretation.
 Finiteness: An algorithm must have a finite number of steps. It should eventually terminate after a
finite number of instructions, either by producing the desired result or by indicating that no
solution is possible.
 Input: An algorithm takes zero or more inputs as information or data on which it operates. The
input can be provided externally or generated within the algorithm itself.

 Output: An algorithm produces at least one output, which is the result or solution to the problem
it is designed to solve. The output can be a value, a set of values, a message, or any other form of
meaningful information.
 Determinism: Each step of an algorithm must be deterministic, meaning that it should produce the
same output for a given input every time it is executed. There should be no randomness or non-
deterministic behavior unless explicitly required.

6|Page
 Effectiveness: An algorithm must be effective in solving the problem it is designed for. It should
provide a correct solution or result within a reasonable amount of time, considering the size of the
input.
 Generalization: An algorithm should be applicable to a wide range of inputs and problem instances.
It should not be overly specific or tailored to a particular scenario, but rather offer a solution that
can be used in different contexts.
 Modularity: An algorithm can be divided into smaller, manageable parts called modules or
subroutines. This allows for easier understanding, implementation, and maintenance of the
algorithm. Modularity also promotes code reuse and scalability.
 Optimality: Depending on the problem being solved, an algorithm may strive to produce an optimal
solution, maximizing or minimizing a specific objective. Optimality is not always a requirement, but
it can be desirable in many cases.
 Efficiency: An algorithm should be efficient in terms of time and space complexity. It should use
the available resources (such as memory and processing power) in an optimal manner, avoiding
unnecessary operations and minimizing resource consumption.

These characteristics collectively define the properties and behavior of an algorithm, enabling it to solve
problems systematically and reliably.

7|Page
3. Example for Algorithm

a. Boil the egg

- Step 1: Prepare eggs and pot

Figure III: Eggs and pot

8|Page
- Step 2: Boiling eggs

Figure IV: Boiling eggs

9|Page
- Step 3: Peel the eggs

Figure V: Peel the eggs

10 | P a g e
- Step 4: The product is cooked eggs

Figure VI: The product is cooked eggs

11 | P a g e
b. Quadratic equation solving algorithm

Figure VII: Quadratic equation solving algorithm

12 | P a g e
II. Steps in program development

The process of program development typically involves several key steps. Here is a general outline of the
steps involved:

- Problem Identification: Clearly define the problem or requirement that the program needs to
address. Understand the objectives and desired outcomes.

Figure VIII: Problem Identification

13 | P a g e
- Planning and Analysis: Gather requirements by studying the problem domain and interacting with
stakeholders. Identify the scope of the program, its functionalities, and constraints. Analyze the
feasibility and potential risks.

Figure IX: Planning and Analysis

- Design: Create a detailed design of the program, including its architecture, data structures,
algorithms, and user interface. This step focuses on breaking down the problem into smaller
components and determining how they will interact.

Figure X: Design

14 | P a g e
- Implementation: Write the code based on the design. This step involves translating the design
specifications into an executable program using a programming language. Follow coding best
practices, conventions, and standards.
- Testing: Thoroughly test the program to identify and fix bugs, errors, and any unexpected behavior.
This includes unit testing (testing individual components), integration testing (testing how the
components work together), and system testing (testing the entire program).
- Documentation: Document the program, including its design, functionality, and instructions for
use. This documentation helps other developers understand and maintain the program in the
future.
- Deployment: Prepare the program for deployment in the target environment. This may involve
packaging the program, creating installers, and ensuring compatibility with the necessary hardware
and software.
- Maintenance: Continuously monitor and maintain the program after deployment. Address any
issues that arise, provide updates, and make improvements based on user feedback or changing
requirements.

It's important to note that program development is often an iterative process, with steps being revisited
and refined as needed. Communication and collaboration with stakeholders, users, and other developers
are crucial throughout the entire process.

15 | P a g e
III. Solve problems using algorithms
1. Math content

With the theory I explained above, I have created a Program Menu for the user to choose to solve problems
about equations. When running the program, the screen will show the options. The user can then select
keys such as:

--------------------------------Solve equations Menu-------------------------------


1. Solve first degree equation
2. Solve quadratic equation
3. Exit

Select choice: ....

When the user presses key 1, the screen will switch to “Solve first degree equation” program.

When the user presses key 2, the screen will switch to “Solve quadratic equation” program.

When the user presses key 3, the program will exit.

2. Problem analysis
This menu is divided into main functions such as:

When the user presses key 1, the screen will switch to “Solve first degree equation” program, when the
user enters a, b, the computer will do the calculations for you to get the solution x.

When the user presses key 2, the screen will switch to “Solve quadratic equation” program, when the user
enters a, b, c, the computer will do the calculations for you to get 2 solutions x1, x2.

When the user presses key 3, the program will exit.

16 | P a g e
3. Program Menu

My program menu is pretty simple, it don’t put a lot of emphasis on graphics, but it’s still optimal for the user, and
here it is:

Figure XI: Program Menu

As you can see, it’s not fancy or anything, it’s as simple as what I described above. I have tried to keep it as simple
as possible for the user, and in the next part I will show you how to works and the code to do it.

17 | P a g e
4. Functional analysis

Figure XII: Flowchart program

This is exactly how my equation solver menu works. You can see, when I start it, it brings up the menu and I
start to fork it with cases, if “choice” is 1, it goes to the first order equation solver, “choice” is 2, it will switch to
the quadratic equation solver and “choice” is 3, it will exit.

18 | P a g e
5. Functions
Let’s start with the functions, the first is the menu part:

Figure XIII: Menu code

In the menu part, I used Console.WriteLine() to let the computer generate the menu like you see above, I split
them into separate lines, and I also added an int function with the variable name “choice” and convert it to
integers with Convert.ToInt32 and allow it to input numbers using the Console.ReadLine().

When the user enters a number in “choice”,


the switch will perform what it is. This part, the
case will take on like a fan switch, then it will
execute the program in that case like I want to
fan it at what level. Then I nested if else if to be
able to branch out the values of the equation,
it’s like when we do a math problem, we need
to use the condition to determine if the value is
correct or with whether the data is given or not
or is it simply for brancing.

Figure XIV: Switch and case and if

19 | P a g e
6. Program Execution

a. When the program starts running, it will show the menu.

Figure XV: When the program is running

20 | P a g e
b. When the user enters 1, the menu will be switched to the first order equation solver

Figure XVI: When enters 1

Figure XVII: Solve first degree equation program.

21 | P a g e
Figure XVIII: When input a and b, result will show

b. When the user enters 1, the menu will be switched to quadratic equation solver

Figure XIX: When enters 2

22 | P a g e
Figure XX: Solve quadratic equation program.

Figure XXI: The equation has 2 distinct solution

23 | P a g e
But if the equation you entered has no solution, the program will return the result “The equation has
no solution”

Figure XXII: When the equation has no solution

And when you enter an equation that has a solution but when delta is 0, the program will also
determine that to give you a double solution.

24 | P a g e
Figure XXIII: When the equation has double solutions

7. Testing and debugging

In the early stages when I was coding, I had a lot of problems like minor errors that I overlooked, it was
quite a waste of my time. In the “choice” section, if you don’t enter a numeric value, it was crash and not
run

25 | P a g e
Figure XXIV: Early stage when coding

Figure XXV: When solve first degreee equation running.

26 | P a g e
Now you can see, the value of “a” before I entered it, its value is 0, its value type is “double”. I
want to use double for it because solving the equation, we can use fractions as the values for a, b.

Figure XXVI: The result is showing when entering a and b

It is similar to solving quadratic equations

Figure XXVII: When entering a before

27 | P a g e
Figure XXVIII: After entering a, b, c and delta, x is showing

28 | P a g e
C. Conclude

In this article, we have explored the concept of algorithms, their defining characteristics, the steps involved
in software development, and a brief overview of menu programming.

An algorithm is a set of ordered steps designed to solve a specific problem. The characteristics of an
algorithm include clarity, input and output, specific scope, and simplicity. Algorithms allow us to organize
actions in a logical sequence and achieve the desired results.

The software development process follows several fundamental steps. Firstly, we identify project
requirements and design the program based on those requirements. Next, we implement the source code
and incorporate the necessary functionality. Then, we perform testing to ensure completeness and
correctness. Finally, we debug and optimize the program for optimal performance.

In this article, we have created a menu program to address equation-related problems. This program
provides users with a simple interface to select and solve equations according to their requirements. By
utilizing algorithms and adhering to the software development steps, we have built an efficient and flexible
menu program.

In conclusion, understanding the concept of algorithms, their defining characteristics, and adhering to the
software development process is crucial in building functional applications. The development of a menu
program for solving equations serves as evidence of the application of algorithms and the software
development process, while also providing a useful tool for users.

29 | P a g e
D.Reference

Gillis, A.S. (2022) “algorithm,” WhatIs.com [Preprint]. Available at:


https://www.techtarget.com/whatis/definition/algorithm

GeeksforGeeks (2023) “What is Algorithm Introduction to Algorithms,” GeeksforGeeks [Preprint].


Available at: https://www.geeksforgeeks.org/introduction-to-algorithms/.

Upadhyay, S. (2023) “What Is an Algorithm? Characteristics, Types and How to write


it,” Simplilearn.com [Preprint]. Available at: https://www.simplilearn.com/tutorials/data-structure-
tutorial/what-is-an-algorithm.

Naveen and Naveen (2023) “What is an Algorithm? Its Types and Characteristics,” Intellipaat
Blog [Preprint]. Available at: https://intellipaat.com/blog/what-is-an-algorithm/?US.

Stages of program development process (Program development steps) || CseWorld Online (no date).
Available at: https://www.cseworldonline.com/articles/stages-of-program-development-process.php.

EADScholars (2020) Steps in Program Development » EADScholars. Available


at: https://eadscholars.com.ng/topic/steps-in-program-development/.

Steps of Program Development Process (no date). Available at: https://qsstudy.com/steps-of-program-


development-process/.

Program Development steps | Study Glance (no date). Available


at: https://studyglance.in/c/display.php?tno=4&topic=Program-Development-steps.

30 | P a g e

You might also like