Docsity

Assignment 1 Programming BTEC C#, Assignments of Programming Paradigms

Toggle sidebar
bg1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
Unit 1: Programming
Submission date
8/12/2021
Date Received 1st submission
Re-submission Date
Date Received 2nd submission
Student Name
Truong Dan Truong
Student ID
GCH200277
Class
Assessor name
Lai Manh Dung
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
Truong
Grading grid
P1
M1
D1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Assignment 1 Programming BTEC C# and more Assignments Programming Paradigms 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 8/12/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Truong Dan Truong Student ID GCH Class Assessor name Lai Manh Dung 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 Truong Grading grid P1 M1 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

    1. State your simple business problems to be solved
      • Overview about algorithm
      • Represent a small and simple problem
    1. Analyze the problem and design the solutions by the use of suitable methods.
      • Analyze the problem
      • Flowchart
    1. Demonstrate the compilation and running of a program
      • Introduce how the problem is solved
      • Source code and screen shots of the final result
      • Explain briefly what is Software Development Life Cycle
      • Explain how the source code is compiled
  • a specific programming language 4. Evaluate how the problem is solved from the designed algorithm to the execution program written by - Test case:........................................................................................................................................
    • written by a specific programming language Evaluate how the problem is solved from the designed algorithm to the execution program
  • References
  • Figure 1-The brow tea algorithm Table of Figure
  • Figure 2- Algorithm is clear from input to output
  • Figure 3- Swap number algorithms include 8 steps
  • Figure 4-Using available resources to handle problem
  • Figure 5-Algorithm can implement in many languages
  • Figure 6-Sorting grade of student problem
  • Figure 7- How bubble sort algorithm works
  • Figure 8-Source code
  • Figure 9-Screenshot of the final result (1)
  • Figure 10-Screenshot of the final result (2)
  • Figure 11-Software Development Life Circle

Table of Flowchart Flowchart 1-Bubble sort algorithm .............................................................................................................. 11 Flowchart 2-How my program solve problem ............................................................................................. 12 Flowchart 3-Example about how C# compiler works .................................................................................. 18

1. State your simple business problems to be solved

Overview about algorithm

  • Definition: An algorithm is a procedure or formula used for solving a problem. It contains the steps, which is a set of actions that are executed in a certain order to obtain the desired output. For example: The brew tea algorithm Figure 1 - The brow tea algorithm
  • Characteristics of algorithm:
    • Unambiguous: The algorithm should be explicit and straightforward. Each of its processes as well as their inputs and outputs, should be obvious and lead to just one conclusion.

Figure 2 - Algorithm is clear from input to output +Finiteness: Algorithm must handle the problem after doing number of certain steps. Figure 3 - Swap number algorithms include 8 steps

  • Feasibility: program can solve problem with given the resources provided.

Represent a small and simple problem

To know about algorithm in programing clearly, I will represent small and simple problem the business problem, it is sorting student by grades in ascending order. This is the problem that the teacher usually meets it when they classify student in a class. Figure 6 - Sorting grade of student problem To handle this problem, I will use bubble sort algorithm because it is simpler than other sorting algorithms. Idea of this algorithm is sorting a list of grades of student by repeating the task of swapping two consecutive grade if they are in the wrong order (the latter grade is less than the previous grade) until the sequence grades has been completely sorted by ascending order. Figure 7 - How bubble sort algorithm works

2. Analyze the problem and design the solutions by the use of suitable methods.

Analyze the problem

  • Input:
    • Total of student.
    • A list of students included student name and their grade.
  • Output: A list of students is sorted by grade in ascending order.
  • Variables are used: Variable Data type Purpose total integer Store total of student name string array Store student name grade double array Store student grade i, j integer Access each of student name or grade tempName string Store temporary name in order to support swapping value tempGrade double Store temporary grade in order to support swapping value Table 1 - Main variables are used
  • Structures are used: Structure Purpose If Compare student information to sort For Access each student information Table 2 - Structures are used

Flowchart

  • Explain by pseudo code: Step 1: START Step 2 : DECLARE tempName, tempGrade, i, j; Step 3 : SET i=0; Step 4 : WHILE i<total-1 is True, REPEAT step 5 through step 9. Step 5 : SET j=i+1; Step 6 : WHILE j<total is true, REPEAT step 7 through step 8. Step 7 : IF grade[i]> grade[j]: Step 7.1: SET tempName= name[i], SET tempGrade=grade[i]. Step 7 .2: SET name[i]=name[j], grade[i]=grade[j]. Step 7 .3: SET name[j]=tempName, grade[j]=teampGrade. Step 8 : INCREASE j by 1. Step 9 : INCREASE I by 1. Step 10 : STOP.

3. Demonstrate the compilation and running of a program

Introduce how the problem is solved

  • In my program, I apply procedural programing to divide this problem into small tasks that includes function readList, printList and sortList. In addition, I have used algorithm that was designed in task 2 to build function sortList. The function readList and printList will support function sortList in reading and displaying result.
  • In detail, my program will read unsorted list of students that included name and grade from keyboard, and then I display this list on console screen. After that, I sort this list by grade and display it on console screen. Flowchart 2 - How my program solve problem

Source code and screen shots of the final result

  • Source code:

I use the algorithm that I have analyzed and designed in task 2 to build function sortList: +I declare 2 variable: tempName and tempGrade in order to store temporary name and grade that will support swapping 2 values (name, grade). +I use 2 for-structures combine if-structure with condition (grade[i]>grade[j]) to check if latter grade less than previous grade. In case this condition is true, I will swap variable name[i] and name[j], grade[i] and grade[j]. ▪ The final step: In method Main, I use 3 above functions to handle problem follow order: Read list of students that has not been sorted→display list before sorting→sorting list→display list after sorting.

  • Screenshots of the final results:

Figure 9 - Screenshot of the final result (1) Figure 10 - Screenshot of the final result ( 2 )

Explain briefly what is Software Development Life Cycle

Software Development Life Cycle is a process that is followed for a software project. It is a thorough strategy that explains how to build, maintain, replace, and modify or enhance certain software. On the other hand, it is an approach for enhancing software quality and the development process in general.

Flowchart 3 - Example about how C# compiler works

4. Evaluate how the problem is solved from the designed algorithm to the execution

program written by a specific programming language

Test case:

Test case ID Test objective Data Expected result Actual result Evaluation T01 List of students after sorting by grade The list includes 3 students and their information are Nguyen Van Long 5 Bui Thi Linh 3 Dang Van Cuong 9. The list of students was sorted by grade in ascending Bui Thi Linh 3 Nguyen Van Long 5 Dang Van Cuong 9. The list of students was sorted by grade in ascending Pass The list includes 5 students and their information are Bui Duc Canh 8. Bui Xuan Truong 9. Ha Thi Linh 7. Do Duc Thang 4. Vu Thi Hue 6. The list of students was sorted by grade in ascending Do Duc Thang 4. Vu Thi Hue 6. Ha Thi Linh 7. Bui Duc Canh 8. Bui Xuan Truong 9. The list of students was sorted by grade in ascending Pass

The list includes 10 students and their information are Nguyen Trong Hue 8. Tang Tien Dat 1. Bui Quang Dung 9. Ngo Minh Quang 5. Cao Viet Anh 7. Nguyen Minh Duc 4. Nguyen Thi Thao 6. Ha Thu Trang 8. Nong Van Lam 6. Truong Hai Dang 10. The list of students was sorted by grade in ascending Tang Tien Dat 1. Nguyen Minh Duc 4. Ngo Minh Quang 5. Nguyen Thi Thao 6. Nong Van Lam 6. Cao Viet Anh 7. Nguyen Trong Hue 8. Ha Thu Trang 8. Bui Quang Dung 9. Truong Hai Dang 10. The list of students was sorted by grade in ascending Pass Table 3 - Test plan

Evaluate how the problem is solved from the designed algorithm to the execution

program written by a specific programming language

Algorithm is ordered steps to solve a certain problem. When we analyze and design the algorithm, we can understand the nature of the problem and the appropriate solution. On the other hand, the computer cannot understand human language, so we have to write it in a suitable programming language that compilers can compile for the computer to understand and run. The program written will be based on the designed algorithm to complete work. Therefore, written algorithm and code variant are closely related in solving problems