



































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
define an algorithm, build a program , SDLC, ...
Typology: Assignments
1 / 43
This page cannot be seen from the preview
Don't miss anything!




































Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date 5/8/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Tran Doan Dung Student ID GCH Class GCH0908 Assessor name 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 Dzung Grading grid P1 M1 D
Grade: Assessor Signature: Date: Lecturer Signature:
An example of an algorithm: Find the maximum value of a 10 - element integer sequence entered from the keyboard. First of all, we need to understand the definition of Input and Output of the above problem.
The following diagram will help us understand more about the requirements of the problem: Figure 2 - Operation diagram of the program To solve this problem, I will use C# language in this program. In addition, I will apply the experience I have gained from Procedural Programming to write programs that are easiest to understand. I will demonstrate how I include the libraries, variables, conditional expressions, and loops that I use to write the program.
In this program I plan to use 2 libraries to meet the needs of the problem. That is:
Basic library of a Console Application, using commands like Console.WriteLine(), Console.ReadLine(), conditional structure, loops, etc.
Library to use List in C#
To solve this problem, I plan to use 3 main data types string, integer and double. Where variables using integer data type will be used for the user's selection in the menu(choice), data type double will be used for the number of students (number), the total score of the students (sum), the total number of students passing the course (count), the intermediate variable to sort the student's score (compare) and the student's score (grade). And finally, the variables that will use the string data type are: the student's name (name), the student's ID (ID), the intermediate variable to change the student's ID according to the score arrangement (sid). To be clearer, I will create a table of the set of variables I use in this program. Data Type Variable Function Integer choice Get user selected silk Double number Declare the number of students sum Calculate the total score of the student count Calculate the number of students who pass the course compare The intermediate variable to sort the student's score grade Declare students’ grade String name Declare the name of the student
To be able to use the features without having to re-enter the data, I will put the features in the “Switch - Case” statement into a “do – while” loop for a repeatable Menu control. program functions for the user to choose from. In addition, I also designed an option to help users exit the program. If the user enters
Figure 4 - Menu Control
During the execution of the program, in order to avoid the user entering the wrong number of students and the student's grades. I will use an additional if statement to check the data entered by the user. I plan to use the following: Figure 5 - Condition of number When the user enters the number of students less than or equal to 0, there will be no students initialized in the value domain of number, so I have set the condition for the number to be greater than 0, the program will not force people. use re-enter Figure 6 - Condition of grade
Figure 8 - Print Student’s Information (Don't Remove List) As in the two images above, the program mistakenly printed information about student Linda's name and ID for student David. Meanwhile, student David's name and ID information is pushed down to student Kate. If the student's ID and name are not deleted, they are still stored in the List. Therefore, when printing List to the screen, it will lead to the phenomenon that the number of times the information is pushed down and the amount of information lost will be equal to the number of incorrect entries of the user's score. You
can refer to the following chart: Diagram 1 - Operation error of the program Since the variable “-7” has been deleted, the program will print out the information in the area bounded by the black line. As can be seen, List name and List ID still receive user input, but that information will not be displayed because the program only prints to Index 2 in this case. Regarding loops in the program, here, I mainly use 2 types of loops, for loops and do-while loops. Here, I will explain about loops in the Main function of the program. As for the loops in Functions, when I come to any Function, I will explain in detail in that Function.
Flowchart: Diagram 2 - Input number student Algorithm (Pseudo code):
Figure 10 - Input student's number Description: When starting to run, the program declares the variable 'i' with integer data type to start running the for loop. The program first checks the condition of the variable 'i'. If the variable 'i' is less than the variable 'number', the program will enter a do=while loop to let the user enter information. Here, the user needs to enter 3 types of information that are the name, ID, grade of each student and the variables respectively:
Algorithm (Pseudo code):