Download database development and design and more Summaries Database Programming 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 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Tran Manh Dat Student ID GCD Class GCD1105 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 Grading grid P1 P2 P3 M1 M2 D1 D
Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date: Lecturer Signature:
- I. PROBLEM STATEMENT
- 1 Scenario
- Reporting Objectives
- I. Define an algorithm and outline the process in building an application. (P1)
- Algorithm
- 1.1. Overview about Algorithm
- 1.2. State a Small Problem, Input, and Output.
- • Problem: Checks if an input positive number is divisible by 2.
- II. Analyse the problem and design the solutions by the use of suitable methods (P1)
- Analyse The Problem
- Flowchart Of Problem
- III. Demonstrate The Compilation And Running Of A Program (P1 – P2)
- Source code
- Explain Source Code
- 2.1. Input Number
- 2.2. Check If The Input Is Greater Than Zero
- 2.3. Other Function (Ask user if want to continue checking other number and Clear screen)
- 2.4. Software Development Life Cycle
- 2.5. Explain How The Source Code Is Compiled (C#)
- IV. Potential Challenges Faced During Coding (M1) - 1.2. Threading issues - 1.3. Performance issues................................................................................................................................................................................... - 1.4. Type mismatch errors - 1.5. Memory leaks - 1.6. Security Vulnerabilities
- V. Evaluate how the problem is solved (D1)
- Include Test Cases
- written by a specific programming language 2. Evaluate how the problem is solved from the designed algorithm to the execution program
- Briefly present the benefits and limitations of this program
- VI. Explain Programming Paradigms (P3)
- What is Procedural Programming?
- What is Object-Oriented Programming?
- What Is Event-Driven Programming?
- Conclude
- source code of an application. (M2) VII. Compare the procedural, object-orientated and eventdriven paradigms used in given
- Example........................................................................................................................................................................
- Conclude
- Reference:
- Figure 1: What is Algorithm...........................................................................................................................
- Figure 2: Advantages of the Algorithm
- Figure 3: Disadvantages of the Algorithm
- Figure 4: Flowchart Of Problem.....................................................................................................................
- Figure 5: Input Number
- Figure 6: Check input > 0 or not
- Figure 7: Check if the number you just entered is divisible by
- Figure 8: After entering number < 0.............................................................................................................
- Figure 9: Other Function
- Figure 10: Software Development Life Cycle
- Figure 11: General Problems
- Figure 12: Personal Problem
- Figure 13: Procedural Programming
- Figure 14: Example of Procedural Programming
- Figure 15: OOP Programming......................................................................................................................
- Figure 16: Illustrations For OOPs Programming
- Figure 17: What is Event-Driven Programming
- Figure 18: Illustrations of Event-Driven Programming
- Figure 19: Code Event-Drivent
- Figure 20: Image after click Run (Event-Driven Program)..........................................................................
- Figure 21: Popup show information input
- Table 1: Example a Small Problem
- Table 2: Test Case
Figure 1 : What is Algorithm Advantages of the Algorithm:
- Efficiency: Algorithms provide a systematic and efficient approach to problem-solving. By breaking down a problem into smaller, more manageable steps, algorithms can help optimize time and resources.
- Accuracy: Algorithms can help ensure accuracy and consistency in problem-solving. By providing a clear set of instructions, algorithms can help reduce errors and discrepancies in the solution.
- Reusability: Algorithms can be reused in different contexts and for other problems. Once an algorithm is designed and tested, it can be applied to similar issues in the future, saving time and effort.
- Scalability: Algorithms can be scaled up or down depending on the size and complexity of the problem. This makes them suitable for various applications, from small-scale operations to large- scale systems.
- Automation: Algorithms can automate repetitive tasks or processes, freeing up human resources for more complex or creative tasks. This can help increase productivity and efficiency in various fields.
- Optimization: Algorithms can optimize various processes, such as resource allocation, scheduling, and routing. This can reduce costs, improve performance, and enhance overall efficiency. Figure 2 : Advantages of the Algorithm
Disadvantages of the Algorithm:
- Limited scope: Algorithms are only effective in solving problems that can be defined and broken down into a set of instructions. Problems that are subjective or require judgment and creativity may not be solvable with algorithms alone.
- Complexity: Complex problems may require complex algorithms, which can be challenging to design, implement, and test. This can increase the time and resources needed to solve the problem.
- Dependence on data: Algorithms rely on accurate and relevant data to produce accurate results. The algorithm may produce unsatisfactory results if the data is complete, accurate, or biased.
- Lack of flexibility: Algorithms are designed to solve specific problems and may need to be more easily adaptable to new or changing situations. This can limit their usefulness in dynamic environments.
- Vulnerability to hacking: Algorithms used for security or encryption can be vulnerable to hacking or other forms of cyberattack. This can compromise the security of sensitive data or systems. Figure 3 : Disadvantages of the Algorithm 1.2. State a Small Problem, Input, and Output. Problem : Checks if an input positive number is divisible by 2. INPUT OUTPUT 66 Number 66 is divisible by 2 Table 1 : Example a Small Problem
- Solution : In this problem, we will use the if function, inside, there is also an if function. Also, use some simple syntax like importing and exporting your desired data.
Figure 4 : Flowchart Of Problem
III. Demonstrate The Compilation And Running Of A Program (P
– P2)
1. Source code
using System; namespace TranManhDat { internal class Program { public static void Main(string[] args) { char continueOrNot = 'y'; int inputNumber, tempNum; do { Console.Write("Write input number: "); inputNumber = int.Parse(Console.ReadLine()); if (inputNumber > 0 ) { if (inputNumber % 2 == 0 ) { Console.WriteLine($"{inputNumber} devisible by 2"); Console.WriteLine($"{inputNumber} : 2 = {inputNumber / 2 }"); } else { tempNum = (inputNumber - 1 ) / 2 ; Console.WriteLine($"{inputNumber} not divisible by 2"); Console.WriteLine($"{inputNumber} : 2 = {tempNum} remainder 1"); } } else { Console.WriteLine("Invalid Number"); } Console.Write("\nDo you want to continue? (Answer: y/n): "); continueOrNot = char.Parse(Console.ReadLine()); Console.Clear(); } while (continueOrNot == 'y'); } } }
- Explain Source Code
2.1. Input Number
Figure 5 : Input Number We need to enter a number so the program can check Here I use Readline Function for input
2.2. Check If The Input Is Greater Than Zero
Figure 6 : Check input > 0 or not
2.2.2. After entering number < 0 Figure 8 : After entering number < 0 When we enter input data < 0, the program will print the result: Invalid Number.
2.3. Other Function (Ask user if want to continue checking other number and Clear
screen)
Figure 9 : Other Function Asked the user if they wanted to continue using the Do-while function.
- This Do-while function will execute the program once before testing the condition.
- We will ask them if they want to continue the program when it is almost over: If yes, enter 'y' to continue. When the variable = 'y' is true to the condition => it will continue to run. Otherwise, the program will stop and complete. I also added the screen clear function: Console.Clear(); (This function used to clear the contents of the Console screen and move the cursor to the beginning of the first line of the Console.)
Implement the project properly to minimize risks. 2.4.3. Design This phase of SDLC begins with converting the software specifications into a design plan known as the Design Specification. The strategy is then reviewed by all stakeholders who provide input and ideas. It is essential to have a system in place for gathering and incorporating stakeholder feedback into this document. Failure at this point will almost certainly lead to cost overruns and, at worst, the complete project collapse. 2.4.4. Software Development Software development turns project requirements and prototypes into tangible solutions. Thus, engineers began to create the entire system by generating code using the necessary technology. During this software development lifecycle phase, customers will be able to get their first look at your future product. And at the end of the build process, the customer will have an operational feature to share with the customer. 2.4.5. Testing All the code is tested to verify and validate a software product at this stage. Then testers perform Software Test Life Cycle activities to monitor the system for bugs and defects. This is done to check the correspondence between a program's actual and expected behavior. The testing and initial SDLC phases can be done with in-house software development and outsourcing, as they require end-user interaction. 2.4.6. Deployment This step aims to deploy the software into a production environment so that users can start using the product. However, many companies prefer to move the product across several deployment environments, such as testing or staging. This step aims to test the product in a secure environment before it goes to market. Utilizing this allows any final flaws to be identified before the product is released.
2.5. Explain How The Source Code Is Compiled (C#)
C# is a modern, high-level programming language that is widely used for developing desktop applications, web applications, games, and other software. Here is a brief overview of how C# source code is compiled and run:
- Writing the source code: A software developer writes C# source code using a text editor or an integrated development environment (IDE).
- Compilation: The C# compiler translates the source code into an intermediate language called Common Intermediate Language (CIL), which is also known as Microsoft Intermediate Language (MSIL).
- Assembly: The CIL code is then assembled into an assembly, which is a collection of files that contains the compiled code, metadata, and resources needed to run the program.
- Just-in-time (JIT) compilation: When the C# program is executed, the Common Language Runtime (CLR) compiles the CIL code into native machine code using a process called just-in- time (JIT) compilation. The compiled code is stored in memory and executed by the computer's processor.
- Execution: Once the JIT compilation is complete, the program is executed by the computer, and the result is displayed on the screen or written to a file, depending on the nature of the program.
IV. Potential Challenges Faced During Coding (M1)
1. General problems
Figure 11 : General Problems
1.1. Null reference exception
The programmer must declare a variable with a specific data type. If a variable is not initialized or is set to null, it may cause a null reference exception error when running the program.
1.2. Threading issues
C# supports multi-threading, which can be useful for improving application performance. However, threading issues can occur when multiple threads access the same data or resources, leading to race conditions, deadlocks, or other problems.
2.1. Distraction Writing code requires a high degree of concentration and attention, and distractions can be especially disruptive. Personal issues like family problems or relationship problems can keep me focused and productive. 2.2. Physical health issues Sitting code continuously for a long time caused me back pain and leg muscle fatigue. 2.3. Burnout Coding can be a demanding and stressful activity, and I can get burned out if they work long hours or constantly face tight deadlines. Burnout can lead to decreased productivity, decreased motivation, and increased stress levels. 2.4. Code without a plan With small tasks, it's okay, big tasks or big projects, after only a few hours of coding, the amount of code in the project increases, many modules, many components come to look back like a bunch of tangled, patched pieces. patch. After a few days of going back to the code, I was dizzy and couldn't remember the structure and flow of the code so that I could continue to code, so I felt discouraged.
V. Evaluate how the problem is solved (D1)
1. Include Test Cases
Test Case Test Content Test Data Expected Result Pass / Fail 1 Enter a negative number Enter: - 9 Invalid Number
PASS
2 Enter a positive number (Even) Enter: 88 88 devisible by 2
PASS
3 Enter a positive number (Odd) Enter: 55 55 is not devisible by 2 PASS 4 Incorrect input data Enter: 9. Stopping the console because the Variable is declared as an integer.
PASS
5 Continue to check another number Enter 10 and enter ‘y’ Continue console
PASS
Table 2 : Test Case