PRO102 ASSIGNMENT 2 DISTINCTION KÈM FILE CODE

37 5 0
PRO102 ASSIGNMENT 2 DISTINCTION KÈM FILE CODE

Đ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

ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PROG102 Procedural Programming Submission date Date Received 1st submission Re submission Date Date R.

ASSIGNMENT FRONT SHEET Qualification BTEC Level HND Diploma in Computing Unit number and title PROG102: Procedural Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Tran Duc Long Student ID GCH210562 Class GCH1106 Assessor name Dinh Duc Manh 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 P4 P5 M3 M4 D2 long ❒ Summative Feedback: ❒ Resubmission Feedback: 2.1 Grade: Lecturer Signature: Assessor Signature: Date: Table of Contents ASSIGNMENT FRONT SHEET A- Introduction B- Task 1: Code explanation and screenshot I Implementation (P4, M3) Libraries in my program Data types in my program Function to create userLogin Function to check whether a character is alphanumeric Function to input integers and float 10 Function to enter student’s information 11 Function to enter and check number of student 12 Function to print captions student's list and print students 13 Function to show student's list 13 10 Function to arrange students by id 14 11 Function to add a new student in the list 14 12 Function to search student by id 15 13 Function to search student grades 15 14 Function to find max and 16 15 The main - menu function 17 16 Algorithms in my program: 20 17 Rules for naming functions, variable names in my program 21 II Program results (P4) 22 C- Task 2: Testing (P5, M4) 25 I Testing 25 1.Test userLogin 25 2.Test id 26 3.Test grade 26 4.Testing program in console screen 26 5.Add a new student 27 6.Find student by id 28 7.Find student by grade 28 8.Find the highest score 29 9.Find the highest score 29 10.Show student’s list 29 11.Exit program 30 II Test plan: 31 Test input: 31 Test function: 32 Overall evaluation of testing part 33 D- Task 3: Evaluation (D2) 34 Overall evaluation of the program 34 1.Strength: 34 2.Weaknesses: 34 3.Future improvements: 34 Evaluation procedural programming in my program 35 Advantages: 35 Disadvantages: 35 Quote: 35 E- Conclusion: 36 A- Introduction We live in a modern society where everything is modern and innovative Every day, there is a lot of innovation, especially in technology When it comes to technology, we must admit that it has permeated every aspect of our lives, from simple devices such as phones and computers to complex programming applications In this assignment, I will discuss student mark management software, specifically how I can use it, detailed explanations of its functions and characteristics, and finally an evaluation of the functions and the overall program In addition, I created options in my program for users to easily select, and each option has its own function and information to create a variety of programs These functions will assist the user in entering student information such as grade or id, and the program will also assist the user in determining which students have the highest and lowest grades, as well as statistics on how many students have good and bad grades B- Task 1: Code explanation and screenshot Scenario: A math teacher wants to manage grades of a class He asks you to help him to write a small application to that He needs to enter student IDs, student’s grades and store these information into separate arrays (integer array for IDs and float array for grades) Then he needs to print all student IDs together with their grades Finally, he needs to know which student has highest grade and lowest grade Your program should be menu based with the options above When an option is done, the program should go back to the main menu so he can choose another option There should be an option to quit program I Implementation (P4, M3) Libraries in my program Everyone is aware that there are numerous libraries available in C And in my program, I used libraries in C to create a student management program, which I will explain in detail below Data types in my program In my program the following data types are used: -Enum: is a user-defined data type It is used mainly to assign names to constants, names that make a program easy to read and maintain And I use this type to declare constants: - Struct is a user defined datatype that allows you to store different types of elements And I use this type to declare student’s information -int: is integer type -float: is an number type -char: is character type Function to create userLogin I create a subfunction: userLogin(char username[],char password[]) In this case, I use the specifier to name the ASCII keyboard input keys: I use while loop purpose when user enter wrong account can re-enter In password, I use getch(); to read characters one by one enter from the keyboard Then I use "if else if" statements to check the condition: +If "ch==enter" will finish entering password +If "ch==BKSP" will delete a character just entered from the keyboard +If "ch==TAB" or "ch==SPACE" then continue typing If it does not fall into the above cases, the asterisks will be printed Next step I use the if else statement to check the username and password: I use the string function “strcmp''(strcmp in library string.h) to compare two strings of username and password If username matches "duclong" and password matches "3907", the login is successful and if incorrect, it will be re-entered Function to check whether a character is alphanumeric I create a function inputCheck(char key[]); Here, I use enum data type: In the inputCheck function, I declare variables res, isFLoat, isChar, size=strlen(key[]).(strlen compares string length in string.h library) Then I use a for loop to check the character In "for" I use "if else" statement to check the condition "!isdigit(key[i])" if ''key[i] =='.' then increment isFloat by one unit if false isChar increments by unit Next I use the "if else if" statement to check the condition: If the input string has more than one '.' then it's a string If the input string has a '.' then it is a real number And if there is no '.' then it is an integer Function to input integers and float I create function inputInteger() and inputFloat to input integers and real numbers ● inputInteger(): I declare input array, read array and use while loop to input integer condition in while: I call the function inputCheck(input) which I talked about in section If the input character is not a number, it will be re-entered C- Task 2: Testing (P5, M4) I Testing 1.Test userLogin We must enter the username and password to access the program If you enter it incorrectly, the program will allow you to re-enter it until you enter it correctly, at which point you will be able to access the data you require 2.Test id When the user enters any non-alphanumeric character, the screen will display "Invalid input, try again" and allow us to re-enter it, until the number is entered, the digit will go to the next step 3.Test grade Similar to test id, when we enter an alphanumeric character, the program will display "invalid input, try again" or enter a number greater than 10 and less than the program will start reentering it until satisfied conditions go to the next step 4.Testing program in console screen -menu: We can choose of choices, each choices has its own case for user to enter their information If user enter the numbers that is not in allowable amount The program will forces user re-entered until correct 5.Add a new student When choosing option 1, the program will let us enter student information to add and display a list of students 6.Find student by id When choosing option 2, the program will let us enter the student's id that you need to find and display that student 7.Find student by grade When choosing option 3, the program will let us enter the student's grade that you need to find and display those students 8.Find the highest score When we choose option 4, the program will show the students with the highest scores 9.Find the highest score When we choose option 5, the program will show the students with the lowest scores 10.Show student’s list When we choice option the program will display a list of all students 11.Exit program When you select option the program will display the words "CAM ON BAN DA DICH VU" and exit the program II Test plan: Test input: Test case ID What is being tested Actual result How Test data Evaluation Input the 1, True Pass number that is 7, 10 True True Pass a choice (0-6), words, and A, b, c, d True True Pass signal Input menu choice ( int choice ) -In menu choice, we have to enter the number in the range of to -In this table testing, I try to input the true number (0-6), words, and signal ( int choice ) -In a part input selection's user, the number of test cases is 3, all successful, because I already have a subfunction to check the character outside the main function Input the 5, True True Pass number that is 8.5, 3.2 True True Pass an integer, real A, b, c, d… True True Pass number, Input the number words, and In this part, I try to input the number that is an integer, real number, words, and signal of students signal -In a part input selection's user, the number of test cases is 3, (int n) all successful, because I already have a subfunction to check the character outside the main function Input id Input name Intput grade Expected result True 3, True True Pass 6.5, 7.5 True True Pass Input id that is A,b,c,d… True True Pass an integer, real In this part, I try to input the number that is an integer, real number, number, words, and signal words and -In a part input selection's user, the number of test cases is 3, signal all successful, because I already have a subfunction to check (int id) the character outside the main function Input normal Duclong True True Pass name, name Duclong123 True True Pass has number In a part input selection's user, the number of test cases is 3, (char all successful name[40]) Input grade 0, True True Pass that is an 12, 22 True True Pass integer, real 6.5, 7.9 True True Pass number, A,b,c,d True True Pass words and In this part, I try to input the number that is an integer, real signal number, words, and signal (float grade) -In a part input selection's user, the number of test cases is 4, all successful, because I already have a subfunction to check the character outside the main function Test function: Test cased What is function tested? Variable char userLogin username[50], char password[50] Result Evaluate Pass In this part when you already input username and password, if true you will be accessed program If false, you will have to enter again Add a new int id student in char name[40] list float grade int n Pass When choosing option 1, the program will let us enter student information to add and display a list of students Find char input student by int id id Pass When choosing option 2, the program will let us enter the student's id that you need to find and display that student Find char input student by int grade id Pass When choosing option 3, the program will let us enter the student's grade that you need to find and display that student Find float max, student int n, with the float grade, Pass highest struct Student score students[] When we choose option 4, the program will show the students with the highest scores Find float min, student int n, with the float grade, lowest struct Student score students[] When we choose option 5, the program will show the students with the lowest scores Show int n student’s struct Student list students[] Pass Pass When we choice option the program will display a list of all students Overall evaluation of testing part There are a total of 12 pass cases The test table provides an overview of the likely cases in the program, and the clear details allow us to better understand the code and the program For example, in a table of input, specifically a menu choice, we can easily see the likely circumstances and determine whether they are entered as true or false Furthermore, the user can easily see the results of each function as well as possible cases with their return data type When the program prints the student's ID along with their grades, the user can see the student's information More specifically, the user can view the statistics of the entire list and determine which students have the highest and lowest scores D- Task 3: Evaluation (D2) Overall evaluation of the program 1.Strength: + Using the "do while" loop in the menu-based section has greatly aided me in creating a complete menu-based Furthermore, I combine, which is very beneficial in making the program more professional and functional + Furthermore, the program runs consistently and smoothly due to the flexible combination of commands Using the statement "isdigit()" immediately assisted my program in determining whether the input characters when the user entered it is true or false in order to ask the user to re-enter or proceed to the next step + Furthermore, each part of my program has its own function, making it easy for not only the user but also the machine to read the code, making the program more clear and coherent + The statements I use are easy to remember and use, such as the "for" loop, "do while", "while" loop, and "if else if" statement or "switch" statement, which is very useful in optimizing their performance The "for" statement, for example, is frequently used to repeat the values within it until the limit is reached + Finally, thanks to the versatile “strcmp” and “strlen” functions, I can create a userLogin that increases the program's security Together with the combination of the key in the ASCII encoding, my program has helped to hide the password, help user to avoid data theft and revealed passwords 2.Weaknesses: + When the number of students is too large, the use of arrays will be limited by the maximum number or may result in memory overflow + My program has not read the save file yet 3.Future improvements: Built a list of program options, entered student data, displayed student list, highlighted and displayed the highest and lowest number, as required by the topic However, I need to add a few features to the program, such as adding phone numbers and email addresses, deleting students from the menu, students' strong points, and family members' names and ages Evaluation procedural programming in my program Advantages: + C is a powerful language because it contains many data types and operators, providing me with a broad platform on which to perform various operations in my program + C is a very flexible, or can be said to be a computer-independent procedural programming language, which allows me to run my code on any machine, many browsers such as dev C++, visual studio, visual studio code without making any changes to the code + C assists me in breaking complex problems down into blocks or smaller functions This modular structure makes my program easier to test and maintain + Procedural programming allows me to easily define the structure of my code and solve any problem in a series of code, particularly functions and variables in my program Disadvantages: + C is a very broad language, but it does not support OPP (inheritance, polymorphism, encapsulation, abstraction, data hiding), and my program lacks those features, which I hope to improve in the future + In the process of writing the program, procedural programming, particularly C language, frequently has errors or undetected errors after every line of code Instead, after writing the program, the compiler displays all errors It makes testing the code in my program extremely difficult + One of the most important functions of a programming language is exception handling Various errors and anomalies can occur while compiling the code Exception handling allows us to detect errors and respond positively, but this feature is not available in my program because I use procedural programming in C Quote: Nguyen Van Hieu Available at:: https://blog.luyencode.net/thuat-toan-sap-xep-bubble-sort/ E- Conclusion: To sum up, everything I wrote above is the detailed explanations, function and characteristic of my student mark management software On top of that, through this assignment I have also learned a lot of new and useful things, and I am sure that those things will support me a lot in the future More specifically, I have a more general view of libraries in C like libraries (stdio.h) stand for standard input output , (string.h), (ctype.h) to classify (and transform) individual characters and even (stdbool) stand for standard boolean Besides, I have a better understanding of operators, operands, and expressions in C, which is very useful in calculating between statements Not only that, but I also learned about selection statements or conditional statements such as (if…else….if) statement, conditional/ternary operator statement and “switch” statement These conditional statements make an important contribution to the formation of my assignment, for instant I use (if else if) statement to check the length and the conditions in each function and (switch case) statement is used to create a menu-based setting so that users can select the options they want Furthermore, I also learned about iteration statements like “for” , “while” and “do…while” and there are no question that each statement has its own characteristic like the “for” loop is usually used when the number of iterations is known , “while” , “do while” loops are often used when the number of iterations is unknown and when calling the “while” , “do while” loops, if the condition is false, the “while” loop will not be executed once but the “do while” loop will execute once In addition, I learned about arrays and strings, understand the array concept and its memory structure, way to declare, initialize and access, knowing about multidimensional Array, string representations and various character and string functions And finally, I learned about functions, in this section, I learned how the function works and its functions in the program The way I see it, it is really convenient for not only me but many other users in making the code more flexible and easy to understand Powered by TCPDF (www.tcpdf.org) Index of comments 2.1 Based on the actual presentation and the report, the student presents parts: Write a program that implements the designed solution; Test the program with a proper test plan (Page 31-33) ; The program is written following coding standards , input data is validated; Analyse test results for future maintenance.;; Evaluate the program, state lessons learnt, advantages, disadvantages, difficulties and future improvements, such as solve many problems when input data is incorrect, show list of student (Id, Name, Grade) which max/min grades, password, validation Powered by TCPDF (www.tcpdf.org) ... 20 17 Rules for naming functions, variable names in my program 21 II Program results (P4) 22 C- Task 2: Testing (P5, M4) 25 I Testing ... 25 1.Test userLogin 25 2. Test id 26 3.Test grade 26 4.Testing program in console screen 26 5.Add a new student... 27 6.Find student by id 28 7.Find student by grade 28 8.Find the highest score 29 9.Find the highest score 29 10.Show

Ngày đăng: 18/12/2022, 05:08

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan