Download Programming Assignment: Algorithm Implementation for a Simple Business Problem and more Exercises Information Technology 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 9/12/ Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Nguyen Dang Khanh Hang Student ID GCD Class GCD1103 Assessor name Pham Thanh Son 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 Khanh Hang Grading grid P1 M1 D
Contents INTRODUCTION: OVERVIEW ABOUT PROBLEM STATEMENTS: ........................................... 4 CHAPTER 1 - STATE YOUR SIMPLE BUSINESS PROBLEMS TO BE SOLVED (P1): .................... 5
- Overview about Algorithm:.......................................................................................... 5
- Represent a small and simple problem: ....................................................................... 9 CHAPTER 2 - ANALYSE THE PROBLEM AND DESIGN THE SOLUTIONS BY THE USE OF SUITABLE METHODS (P1): ................................................................................................. 10
- Analyse the problem: ................................................................................................. 10
- Flowchart: .................................................................................................................. 11 CHAPTER 3 - DEMONSTRATE THE COMPILATION AND RUNNING OF A PROGRAM (P1- M1): ......................................................................................................................................... 12
- Introduce how the problem is solved: ....................................................................... 12
- Source code and screen shots of the final result:....................................................... 12 ➢ PROGRAM: ........................................................................................................... 12 ➢ RESULT: ................................................................................................................ 19
- Explain briefly what is Software Development Life Cycle: .......................................... 21
- Explain how the source code is compiled: ................................................................. 23 CHAPTER 4 - EVALUATE HOW THE PROBLEM IS SOLVED FROM THE DESIGNED ALGORITHM TO THE EXECUTION PROGRAM WRITTEN BY A SPECIFIC PROGRAMMING LANGUAGE (D1): ......................................................................................................................................... 24
- Testing: ...................................................................................................................... 24 ➢ TEST PLAN ............................................................................................................ 24 ➢ TEST CASE ............................................................................................................. 25
- Evaluate how the problem is solved from the designed algorithm to the execution program written by a specific programming language: ................................................. 27 REFERENCES ..................................................................................................................... 29
Table of Figure:
- Figure 1: Algorithm
- Figure 2: Types of Algorithms
- Figure 3: Flowchart
- Figure 4: Flowchart of Library Management
- Figure 5: Declare
- Figure 6: Switch cases
- Figure 7: Display Book
- Figure 8: Input Books
- Figure 9: Input Authors
- Figure 10: Menu..........................................................................................................................................
- Figure 11: Class Authors
- Figure 12: Input Authors
- Figure 13: Authors.....................................................................................................................................
- Figure 14: Authors
- Figure 15: Class Books
- Figure 16: Infor of Books
- Figure 17: Books
- Figure 18: Menu..........................................................................................................................................
- Figure 19: Add Books
- Figure 20: Display added books
- Figure 21: Add Authors
- Figure 22: Exit Program
- Figure 23: SDLC
- Table 1: Test Plan.............................................................................................................. Table of Table:
- Table 2: Test Cases
CHAPTER 1 - STATE YOUR SIMPLE BUSINESS PROBLEMS TO BE SOLVED (P1):
1. Overview about Algorithm: Figure 1 : Algorithm − Definition: Algorithms are a type of critical vehicle that you use to understand and accomplish solutions. An algorithm, in more concrete terms, is a set of instructions or techniques for completing particular issues from a starting state; when these methods or methods are employed optimally, the output is as predicted. Thanks to the algorithm, you can do job more quickly and accurately. − Characteristics of algorithm:
- Be limited : Even though the algorithm was developed to assist individuals in achieving things earlier, it must be restricted and completed after specific stages.
- Input: Either have zero or several problems to solve.
- Output: At least one. The number of outputs equals the number of inputs.
- Exact: The procedure must be accurate step by step since you cannot get the optimum result if any particle is incorrect.
- Effective: Every problem has a solution or an algorithm to deal with it. − Types of Algorithm:
- Here are 9 types of algorithms:
Figure 2 : Types of Algorithms
- Sort Algorithms: Sorting algorithms are frequently used by developers to arrange data. The QuickSort algorithm compares data pieces to each other to determine their order. To perform the comparison, it takes O(nLogn) time. Radix Sort, on the other hand, is a quicker approach than QuickSort since it sorts items in a linear model with O(n) time complexity. This algorithm's popularity stems from its simplicity. Merge Sort, Group Sort, and Counting Sort are some more sorting algorithms. ✓ Example: − Write algorithm of P(x)= ax^2 +bx+c with a#
- Describing the algorithm by listing: Step 1: Input a,b,c Step 2: Calculate Δ Step 3: If Δ>0, announce that the equation has x1, x2 distinct and stop. x1= (-b + - √ d) / (2a) x2 = (-b - √ d ) / (2a) Step 4: If Δ<0, announce that impossible equation and stop. Step 5 : If Δ=0, announce that the equation has double root x1=x2=−b/2a and stop.
- Describing the algorithm by flowchart:
Figure 3 : Flowchart
2. Represent a small and simple problem: ✓ According to current research, many people visit libraries to read and borrow books, but they do so manually, scouring the whole library for the volumes they require over a lengthy period of time. As a result, having a library management tool is extremely necessary in order to easily search for books, book categories, and author names. Any library user should be able to search for books by title, author, and release date.
2. Flowchart: Figure 4 : Flowchart of Library Management
CHAPTER 3 - DEMONSTRATE THE COMPILATION AND RUNNING OF A PROGRAM
(P1- M1):
1. Introduce how the problem is solved: − In this section, I will analyze the business issue and translate it into the article's application requirements. Then, using flowcharts and other diagrams, I'll create an algorithm to imitate how they function and solve their problems. Microsoft Visual Studio 2022 is the supporting tool for which I create code; in this post, I will use C# to build problems. 2. Source code and screen shots of the final result: ✓ I divided the program into classes: main class, book class and author class. ✓ Book class includes details about information of book to add it. ✓ Author book includes about information of authors. ✓ Main class includes options in menu. ➢ PROGRAM: − To start, I declare the libraries used in the program. There are System library, System.Collections.Generic library, System.Linq, System.Tex, and System.Threading.Tasks. − As this picture, I create a List to manage the list of authors and books. Then I declare the integer variable choose.
− We use do-while to execute the menu (we the program will work continuously until you enter option 7,then the program will stop). Then, using the "ShowMenu" function, display the menu and input a selection. To branch the program, use the switch case. − Each case corresponds to the requirements of the program. With case 1, implement the input book. Case 2, it shows the information of books. Case 3, it input author and exits the program is case 4. − Program exits the switch block when it reaches the “break” keyword. This will stop the execution of additional code and case testing within the block. Figure 7 : Display Book − As this picture, it has the function of display information of book. − With “InputBook” is input information of book − With “InputAuthor” is input information author. Figure 8 : Input Books
Figure 9 : Input Authors − Menu: Figure 10 : Menu − In this here, users can look at the menu to select another function as desired − Class Author:
Figure 12 : Input Authors 1 − In this function, I use to input information of author include: name, birthday, nickname, address and check nickname is duplicated. Figure 13 : Authors − I use “Display” function to display the information of author.
Figure 14 : Authors 2 − Class Book: Figure 15 : Class Books − To start, I declare the libraries used in the program. There are System library, System.Collections.Generic library, System.Linq, System.Text, System.Threading.Tasks. − Design class Book includes attributes Name, Release Date, Nickname and set { get; private set; } for its.