Docsity

assignment 1 Programing Merit, Schemes and Mind Maps of Windows Programming

Toggle sidebar
bg1
1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
21/06/2023
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
TRAN QUOC ANH
Student ID
BH01310
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
QUANH
Grading grid
P1
M1
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c

Partial preview of the text

Download assignment 1 Programing Merit and more Schemes and Mind Maps Windows 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 21/06/2023 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name TRAN QUOC ANH Student ID BH 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 QUANH Grading grid P1 M1 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

Figure 3: The first- degree equation ............................................................................................................... 9 Figure 4: Flowchart for finding solution of first-degree equations .............................................................. 12 Figure 5: The code of my program ............................................................................................................... 13 Figure 6: Enter a ........................................................................................................................................... 14 Figure 7: Enter b ........................................................................................................................................... 14 Figure 8: Print x ............................................................................................................................................ 15 Figure 9: When a=0 and b=0 ........................................................................................................................ 15 Figure 10: when a = 0 and b ≠ 0 ( b = 5) ..................................................................................................... 16 Figure 11: Compilation process of C# code ................................................................................................. 18 Figure 12: test 1 ............................................................................................................................................ 21 Figure 13: Test 2 ........................................................................................................................................... 21 Figure 14: Test 3 ........................................................................................................................................... 22 Figure 15: Test 4 ........................................................................................................................................... 22 Figure 16: Test 5 ........................................................................................................................................... 23 Figure 17: Test 6 ........................................................................................................................................... 23 Figure 18: Test 7 ........................................................................................................................................... 24 Figure 19: Test 8 ........................................................................................................................................... 24 Figure 20: Test 9 ........................................................................................................................................... 25 Figure 21: Test 10 ......................................................................................................................................... 25

I. INTRODUCTION

Since they were first developed, algorithms have aided people in various disciplines, including math, physics, And in the modern 4.0 era, they actively assist many scientific endeavors. calculator. By resolving each algorithm and integrating them, they make the process of developing high-tech software and goods easier for individuals. I will discuss the idea of algorithms, give real-world examples of algorithms, offer a tiny problem and explain how to solve it using algorithms, diagrams, and the C# programming language in this assignment.

II. BODY

A. State your simple business problem to be solved

1. Definition of Algorithm

A procedure or collection of decisions used in estimating or other problem-solving processes is known as an algorithm. The basis of data programming is said to be algorithms. It includes guidelines, requirements, or methods for completing the initial state. When the requirements are carefully planned, the algorithm will display precise results.

Exemple for algorithm

Solving a rubik’s Cube There are a number of different algorithms, from simple to very complicated, that exist for solving a Rubik’s cube. Below is just one simple algorithm that significantly reduces the amount of time to solve this famous puzzle. First, let’s specify a notation to use (similar to picking a programming language). Each of the six faces of a Rubik’s cube can be represented by the first letter of their name: Figure 1 : What is the algorithm

Step 1: The Cross First, flip some edges so that there is a white cross on the upper face. Apply the following turns: F, R’, D’, R, F2, R’, U, R, U’, R’, R2, L2, U2, R2, L2. The cross is now solved. Step 2: The White Corners The edges on the white face are now complete, but the corners remain. Depending on where the white-orange-green corner is in the puzzle, apply one of the following series of turns: Bottom: R’, D’, R, D (repeat until the corner moves to its correct place). Top: R’, D’, R, D (this moves the corner to the bottom; then, follow the above instructions). Step 3: Middle Layer Edges Flip the cube so that the white is on the bottom. Look for an edge that is on the top face and doesn’t have yellow on it. Perform a U-turn so that the color on the front face of the edge matches with the center. Depending on the direction that the edge could go, apply one of the following series of turns: Left: U’, L’, U, L, U, F, U’, F’. Right: U, R, U’, R’, U’, F’, U, F). Step 4: Yellow Cross Apply the following turns, until a yellow cross on the face appears with the yellow center: F, R, U, R’, U’, F’. If there is an “L” shape, where the two yellow pieces showing are adjacent to each other, apply the following turns: F, U, R, U’, R’, F’. If there is a “Line” shape, which is horizontal, apply the following turns: F, R, U, R’, U’, F’. Step 5: Sune and Antisune

Look at the face with the yellow center. Depending on the below contingencies, apply one of the following series of turns: If there is only one oriented corner: R, U, R’, U, R, U2, R’ (repeat until the desired position is attained) There is one oriented corner and one right-facing corner: U2, R, U2, R’, U’, R, U’, R’. Step 6: Finishing the puzzle Look for sets of “headlights” (two stickers of the same color in the same row, separated by a sticker of a different color). Depending on how many there are, apply one of the following series of turns: If there are a set of headlights on each side: R, U’, R, U, R, U, R, U’, R’, U’, R Otherwise: R’, F, R’, B2, R, F’, R’, B2, R

2. Characteristics of algorithm

An algorithm must possess following characteristics:

Finiteness: An algorithm must conclude at some point in time. This is essential for all algorithms; otherwise, they will continue into an unending loop and never be completed. Definition: Every algorithm must be precise and unambiguous. Effectiveness: Every algorithm should follow fundamental principles. We should make an effort to write simply so that it would be important. Input: Each algorithm must accept input, which is often zero or at least one. Therefore, the client may use it in accordance with the terms. Output: There must be some sort of output for any effort; this is a very minimum need; otherwise, there is no use in doing any work. Similar to this, each algorithm should provide at least one output.

Purpose: Program is written to calculate x in a first- order equation Algorithm: Using 2 conditional statements: The program will first check to see whether a = 0, then it will provide the answer before ceasing to run. The second conditional expression will be used if an is not zero. The following step is to compare b. The equation has no solution if b = 0, else it contains an unlimited number of solutions. B. Analyze the problem and design the solution by the use of

suitable methods.

1. Analyze the business problem

a. Specifying the input requirements My software needs two numbers as input. Any integer has the potential to also be a real number. No Variable Data type Description Figure 3 : The first- degree equation

1 a Float This Variable stores the value of the coefficient a 2 b Float This Variable stores value of the coefficient b Table 1 b. Specifying the output requirements My software should produce 1 number as its result. can either be an integer or a real number. If the equation has infinitely many solutions or no solution at all, then there must also be another message. No Variable Data type Description 1 X Float This Variable stores the result of the 1st^ degree equation (ax + b = 0) with x = - b / a Table 2 c. Specifying the processing requirements The chapter must deal with 3 conditions: If a ≠ 0, the solution gives x = - b / a. If a = 0 and b ≠ 0 output the equation has no solution. If a = 0 and b = 0 output the equation has a multitude of solution.

  1. Design the algorithm a. What is the design? A design is a route from the issue to a code-based resolution. b. The well-designed program is likely to be Easier to read and understand later. Less of bugs and errors.

Figure 4 : Flowchart for finding solution of first-degree equations

C. Demonstrate the compilation and running of a program.

1. Coding:

After designing the flowchart, I start coding and here is my code: Figure 5 : The code of my program

c. Enter b ( with b = 9 ) Figure 8 : Print x Explain: In the variable b, the program will save the coefficient b (for example, b = 9). The answer to the equation (ax + b = 0) will be displayed when the user touches the "Enter" key (for example, x = - 1.8). d. When a = 0 and b = 0 Figure 9 : When a=0 and b= When the user enters a and b equal 0, the program will have infinite solution and print"This

equation has a multitude of solution”. e. When a = 0 and b ≠ 0 ( b = 5 ) Figure 10 : when a = 0 and b ≠ 0 ( b = 5) When the user types in a = 0 and b 0 (for example, b = 5), the application will output "This equation has a no solution" and have an infinite solution.

3. An explanation of how the source code is compiled and run in C#.

Step-by-step process of C# code compilation: Step 1: Write a C# code Step 2: Compile the code using a C# compiler. Step 3: The compiler now checks to see if there are any errors in the code. The compiler moves on to the next stage if there are no errors. Or, if the compiler discovered errors, it would notify the developer right away that an issue was discovered in the specified line, allowing the developer to fix it. When you rerun the code after fixing the problem, the compiler does a last check for errors; if none are present, it advances to the next stage; otherwise, it notifies the developer of the error. There are two categories of mistakes in C#: Compiler error : Compile-Time errors are those that happen when a developer breaks the norms of proper syntax usage. A correction must be made before the code may be built, according to this compiler issue.

Figure 11 : Compilation process of C# code D. Evaluate how the problem is solved from the designed

algorithm to the execution program written by a specific

programming language.

1. Test Plan

Creator: Tran Quoc Anh Create Date: 19/06/ No. Test case Funcion Test data Expected output Actual Output Result 1 Verify that the results of the first-order equation will be displayed correctly when the user enters a > 0 and b

Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a a = 2 b = 10 x = - 5 X = - 5 Pass

Verify that the results of the first-order equation will be displayed correctly when the user enters a > 0 and b < 0. Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = 2 b = - 10 x = 5 x = 5 Pass 3 Verify that the results of the first-order equation will be displayed correctly when the user enters a = 0 and b

Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = 0 b = 5 The equation has no solution. The equation has no solution. Pass 4 Verify that the results of the first-order equation will be displayed correctly when the user enters a = 0 and b < 0. Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = 0 b = - 6 The equation has no solution. The equation has no solution. Pass 5 Verify that the results of the first-order equation will be displayed correctly when the user enters a = 0 and b = 0. Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = 0 b = 0 The equation has a multitude of solution. The equation has a multitude of solution. Pass 6 Verify that the results of the first-order equation will be displayed correctly when the user enters a is the letter and b > 0. Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = a b = 7 The program has an error message and asks to re- enter. Back to part code and error message. Fail 7 Verify that the results of the first-order equation will be displayed correctly when the user enters a > 0 and b is the letter. Calculate the result of the first-order equation ( ax + b = 0 ) by x = - b / a. a = 6 b = b The program has an error message and asks to re- enter. Back to part code and error message. Fail