1. Trang chủ
  2. » Luận Văn - Báo Cáo

Assignment of PROGRAMMING (1618)

50 15 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 1,44 MB

Nội dung

Dựa trên các chỉ định và yêu cầu trong assignment, nếu bạn tuân thủ chúng một cách nghiêm ngặt và thực hiện công việc một cách cẩn thận, thì khả năng thành công của bạn là tuyệt đối, đạt tỷ lệ 100%. Bằng cách đáp ứng đầy đủ mọi yêu cầu và làm việc chăm chỉ, bạn sẽ đạt được kết quả mà bạn mong muốn.

1 ASSIGNMENT FRONT SHEET Qualification BTEC Level 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 VU THANH TRUONG Class Student ID GCH211415 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 Grading grid P1 M1 D1 TRUONG  Summative Feedback: Grade:  Resubmission Feedback: Assessor Signature: Date: Lecturer Signature: Table of Contents INTRODUCTION: P1 Provide a definition of what an algorithm is and outline the process in building an application: I General properties and limitations of the algorithm: Algorithm definition: Some algorithms: Examples of algorithms: 11 II Feature algorithm: 12 III Software Development Life Cycle (SDLC): 14 Definition: 14 IV Represents a small and simple problem: 16 V Problem solving: 16 Libraly: 17 Data type and variable: 18 VI Use-case diagrams: 20 VII Flow chart: 22 Menu option: 22 Input ID, name and score: 25 Output student ID, name, score: 27 Output find the students with the highest scores: 28 Output find the student with the lowest score: 30 M1 Determine the steps taken from writing code to execution: 33 I coding standards: 33 Declare libraries, variables and arrays: 33 Select menu function: 33 Code enter the information of all students: 34 Code print all student information: 34 Code find the student with the highest score: 36 Code find the student with the lowest score: 37 End program: 38 Default: 38 II Results of the program: 39 Enter student information: 40 Print all student information: 40 Print out the students with the highest scores: 40 Print out the students with the lowest scores: 41 End program: 42 D1 Examine the implementation of an algorithm in a suitable language Evaluate the relationship between the written algorithm and the code variant: 42 I Testing: 43 II Evaluation: 46 Advantages of the program: 46 Disadvantages and difficulties of the program: 46 Future progress improvements: 46 III Conclusion: 47 REFERENCES: 47 INTRODUCTION: Algorithms are a very important concept in programming It represents a set of instructions arranged in a particular way to solve a particular problem In the C# programming language, there are many different algorithms to solve different problems Some of the popular algorithms in C# include sorting algorithms (like Bubble Sort, Insertion Sort, Quick Sort), search algorithms (like Linear Search, Binary Search), recursive algorithms (like Fibonacci, Factorial) and many more algorithms In C#, we can easily use these algorithms through the language's standard library or write our own algorithms If we want to write our own algorithms, C# provides you with the necessary tools to this, including classes and methods that allow you to create and use algorithms However, when using algorithms in C#, we need to consider factors such as performance, correctness, and security This is especially important when you use algorithms for applications that require complex computations or handle sensitive data In short, algorithms are an important part of programming and C# gives you many options to use or write your own algorithms However, they need to consider factors such as performance, correctness, and security when using algorithms in C# P1 Provide a definition of what an algorithm is and outline the process in building an application: I General properties and limitations of the algorithm: Algorithm definition: An algorithm is a specific set of steps designed to solve a problem or perform a certain task These steps are determined by analyzing and classifying the elements in the problem to be solved and making appropriate choices and decisions to achieve the desired outcome Algorithms are commonly used in computer science, mathematics, and other engineering fields to solve complex problems and perform tasks such as searching, sorting, calculating, coding, and coding data decoding, and much more 34 In my program, I have arranged the menu inside the "do-while" statement and outside the "switch-case" statement The reason for this is to provide the user with the ability to return to the menu after completing a function and to facilitate the selection of other functions in the menu as they wish In this way, users can easily search and perform various functions without having to exit the program completely Code enter the information of all students: ▪ Case is the function to enter the information of the students When the user chooses case 1, the program will ask to enter the number of students to enter the information, the highest score and the lowest score that the student can achieve After entering these values, the program will call the inputStudentInfo function to enter the information of the students In this function, for each student, the program will ask for the student's number, the student's name and the student's score After that, the program will check whether the entered score is within the allowed range or not If the score is not valid, the program will ask to re-enter After entering the information of all students, the program will return to the main menu and wait for the user to select the next function 35 Code print all student information: ▪ Case of the above program is used to print out the information of all the students that have been entered into the system Specifically, when the user selects Case 2, the function printAllStudentInfo is called to print out the information of all students 36 The printAllStudentInfo function takes an array of student information as input, including student ID, student name, and student score The parameter n represents the number of students entered into the system This function uses a for loop to iterate over each student in the list and print out each student's information using the Console.WriteLine() command Code find the student with the highest score: ▪ Case 3: Find student with highest score The task of Case is to find the student with the highest score in the list of students entered in Case and print the information of the student with the highest score on the console screen Implementation steps: Declare variables maxscore and peoplemax with initial values of the first student's score and the second student's id, respectively Iterate through the entire list of students using a for loop from to n 37 At each loop, compare the current student's score with the maxscore value If the current student's score is greater than maxscore, assign the value of maxscore to the current student's score and assign the value of peoplemax to the current student's id Browse the list of students again, find students with scores equal to maxscore and print that student's information on the console Code find the student with the lowest score: ▪ Case in this program is used to find the student with the lowest score in the entered list of students When the user selects case 4, the program calls the findStudentWithMinScore function to perform the search This function takes as input array id, name, score and number of students n In the findStudentWithMinScore function, we first initialize the minscore variable with score[0] and peoplemin with id[0] Then we go through each student on the list and compare that student's score with minscore If that student's score is less than minscore, we update minscore and peoplemin with that student's information 38 After going through all the students, we go through the score array to print out all the students whose scores are equal to minscore For each student with a minscore score, we print out information about that student, including name, id and score If there is no student with the lowest score, the program will not print any information So case is used to find the student with the lowest score in the entered list of students End program: ▪ ▪ Case in the above program has the function to end the program When the user selects case 5, the program will print the message "Exit." and exit the do-while loop Then the program will stop and end Here is the detailed analysis of case 5: When the user selects case 5, the program will print the message "Exit." with the Console.WriteLine("Exit."); command After that, the do-while loop will end because the variable choice has been assigned the value Therefore, the program will not execute the instructions in the switch case anymore The program will continue to execute the commands below do-while, if any In this case, the program has only declaration statements and no instructions will be executed after the loop ends The program will stop and end Default: In the switch case of this program, if the user enters an invalid value, the program will switch to the default case and give the user a "Please re-enter" error message 39 This happens when the input value is not among the values selected in the menu (1, 2, 3, 4, 5) So the program will not perform any action and ask the user to re-enter a valid value II Results of the program: 40 Enter student information: Print all student information: 41 Print out the students with the highest scores: Print out the students with the lowest scores: 42 End program: D1 Examine the implementation of an algorithm in a suitable language Evaluate the relationship between the written algorithm and the code variant: I Testing: 43 Testing Objective Input validation for number of students Input validation for number of students Input validation for number of students Test Case Test Data n = -5 n=0 Input Expected Output Actual Output Test Result -5 "No students" "No students" Passed "No students" "No students" Passed "No students" "You entered an invalid score, please try again." "You entered an invalid score, please try again." "You entered an invalid score, please try again." (for score 55), "You entered an invalid score, please "No students" "You entered an invalid score, please try again." "You entered an invalid score, please try again." "You entered an invalid score, please try again." (for score 55), "You entered an invalid score, please n = 105 105 Input validation for highest score m = -5 5 Input validation for lowest score k = 105 Input validation for score range k = 50, m = 40 2, 55, 35 Passed Passed Passed Passed 44 Input validation for score range 10 Input validation for score range Input validation for ID Input validation for ID 11 Input validation for score 12 13 Input validation for score Finding student with highest score try again." (for score 35) try again." (for score 35) "You entered an invalid score, please try again." (for score 101) Passed "You entered an invalid score, please try again." (for score 1) Passed k = 0, m = 100 2, 55, 101 k = 0, m = 100 2, 55, -1 "You entered an invalid score, please try again." (for score 101) "You entered an invalid score, please try again." (for score 1) None (loop skipped) None (loop skipped) None (loop skipped) "All student info:", "ID: 1, Name: test, Score: 0" "All student info:", "ID: 1, Name: test, Score: 100" "Student with highest score: Name: test None (loop skipped) "All student info:", "ID: 1, Name: test, Score: 0" "All student info:", "ID: 1, Name: test, Score: 100" "Student with highest score: Name: test ID = ID = -5 -5 score = 1, test, score = 100 1, test, 100 One student 1, test, 50 Passed Passed Passed Passed Passed 45 14 Finding student with highest score Multiple students 1, test1, 50, 2, test2, 60 15 Finding student with highest score Multiple students with same score 1, test1, 50, 2, test2, 50, 3, test3, 50 16 Finding student with highest score All students have the same score 3, test3, 70, 4, test4, 70, 5, test5, 70 17 Finding student with lowest score Multiple students 1, test1, 50, 2, test2, 60 18 Finding student with lowest score Multiple students with same score 1, test1, 50, 2, test2, 50, 3, test3, 50 19 Finding student with lowest score All students have the same score 3, test3, 70, 4, test4, 70, 5, test5, 70 ID=1, score=50" ID=1, score=50" "Student with highest score: Name: test2 ID=2, score=60" "Student with highest score: Name: test1 ID=1, score=50" "Student with highest score: Name: test3 ID=3, score=70" "Student with lowest score: Name: test1 ID=1, score=50" "Student with lowest score: Name: test1 ID=1, score=50" "Student with lowest score: Name: test3 "Student with highest score: Name: test2 ID=2, score=60" "Student with highest score: Name: test1 ID=1, score=50" "Student with highest score: Name: test3 ID=3, score=70" "Student with lowest score: Name: test1 ID=1, score=50" "Student with lowest score: Name: test1 ID=1, score=50" "Student with lowest score: Name: test3 Passed Passed Passed Passed Passed Passed 46 ID=3, score=70" ID=3, score=70" II Evaluation: Advantages of the program: ▪ ▪ ▪ ▪ The program has a clear and user-friendly interface that allows users to choose from a menu of options The program uses arrays to store student information, which allows for easy access and manipulation of data The program uses a do-while loop to ensure that the user can continue using the program until they choose to exit The program has error handling, such as demonstrating that the user inputs valid scores for each student Disadvantages and difficulties of the program: ▪ ▪ ▪ ▪ The program has a fixed limit of 100 students, which may not be enough for larger datasets The program does not sort the student data in any way, which could make it difficult to find specific students or analyze the data further The program does not allow for editing or deleting student data once it has been entered The program assumes that each student has a unique ID, which may not always be the case in realworld scenarios Future progress improvements: ▪ ▪ ▪ ▪ Allow for dynamic resizing of arrays based on the number of students entered Implement sorting algorithms to sort the student data by ID, name, or score Add functionality to edit or delete existing student data Add error handling for cases where multiple students have the same ID or name 47 III Conclusion: In a nutshell, this program is a basic console application that allows users to enter, store, and manipulate student information such as IDs, names, and grades The program has a number of advantages such as simplicity, user-friendliness and the ability to find students with the highest and lowest scores However, it also has some limitations and difficulties, including a fixed maximum number of students, potential input errors, and limited functionality In the future, this program can be improved by adding more features such as sorting students by grade, searching for a specific student by name or ID, and adding data validation to prevent incorrect input In addition, it can be adapted to store and retrieve data from a database instead of an array to handle a larger number of students Overall, this program provides a good foundation for student information management, but could be further improved and enhanced to increase the usefulness and flexibility of the program REFERENCES: ▪ Source of images in sections: INTRODUCTION [Online] Available at: https://www.educba.com/introduction-to-algorithm/ [accessed March 28, 2023] Algorithm definition [Online] Available at: https://dev.to/habinezajanvier/algorithm-and-data-structuresfor-non-computer-scientists-programmers-3f6p [accessed March 28, 2023] Some algorithms: [Online] Available at: https://kotakode.com/blogs/11972/Definisi-Dan-TujuanRekayasa-Perangkat-Lunak [accessed March 28, 2023] Feature algorithm [Online] Available at: https://byjus.com/sitemaps/gate-sitemap.xml [accessed March 28, 2023] 48 Software Development Life Cycle (SDLC): Definition [Online] Available at: https://medium.com/pragmatech/proqram-t%C9%99minat%C4%B1-software-v%C9%99-onunh%C9%99yat-d%C3%B6vr%C3%BC-life-cycle-1755f2c9d5b7 [accessed March 28, 2023]

Ngày đăng: 17/06/2023, 16:30

w