Assignment 1 PRO102 Greenwich

29 237 5
Assignment 1 PRO102 Greenwich

Đ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

Note: Nếu muốn support C, C#, Networking, Database, project web, 1633, security_zalo 0962.986.805 or fb https://www.facebook.com/profile.php?id=100080073517431. Assignment 1 môn Programing (PROG102) đại học Greenwich 2021. Bài luận đạt điểm chuẩn Merit với trích dẫn học thuật harvard. Dựa vào để hoàn thành điểm M là không khó. Giá tiền phải chăng, dành cho người không có thời gian để làm luận hoặc không có form hướng dẫn. Bạn cũng có thể tìm asm2 của môn này bởi vì mình có đăng trọn bộ. Goodluck

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 Student ID Class 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 P2 P3 M1 M2 D1   Summative Feedback: Resubmission Feedback: 2.1 Grade: Lecturer Signature: Assessor Signature: Date: ASSIGNMENT Analysis and design a solution for procedural programming problem Contents Introduction to programming language and procedural programming 1.1 Programming language 1.2 Procedural programming 1.3 Problem statement 1.3.1 Problem and solution 1.3.2 Apply procedural programming for this problem Analysis 2.1.Data types and data structure 2.2.Conditional sentences 2.3 Loop 10 2.4 Switch-Case 12 Design 13 3.1 Use-case 13 3.2 WBS 14 3.3 Flowcharts 15 3.4 Better solution 24 Evaluation 24 4.1 About my solution 24 4.2 Evaluate how procedural programming is applied to your problem 25 Conclusion 26 Reference list 26 Introduction to programming language and procedural programming 1.1 Programming language Programming language is a type of language that is standardized according to a system and has its own rules It’s used to describe the workings of machines, machines and humans can understand Currently we have a lot of programming language such as Java, C++, JavaScript, but Python is a widely used langue, it can replace Java in the future (Kumar and Dahiya, 2017) 1.2 Procedural programming Procedural programming is a programming paradigm, first appeared in 1957-1964, it works based on procedure which is a series of computational steps to be performed, any procedure can be included during program execution It has few key features: • Programming libraries: It’s a collection in which there are processes, values and pre-existing code, we and the program can use it For example: has calculation functions, contains text corrections We also use many other things • Local variable : Declared and used in the code that contains it in the main body of the program For example: int i, float a, double b,… There are very common and come in many forms • Global variable: Declared outside a block(main) and can be used throughout the program It only ends when the program ends We can use variable “all” anywhere, it’s declared outside main • Parameter: It is a type of variable passed to a function with a unique value and a specified data type Parameter For example: We pass the score parameter to the variable to calculate or print out the information I can also pass parameter in with keyboard input int score; scanf(“%d”,&score); • Modularity: It is an operation where the system is broken down to make it easier to perform when dealing with large, complex programs • Procedure: Procedures are one-by-one instructions that are carried out in programming They flow from one to the next in a sequential manner, so after the one above is finished, it will move on to the next unless the one above tells it not to (Moore, 2014) • Programming paradigms: Procedural programming, object-oriented programming, and flow programming • There are many types of code samples: condition (if, if else), loop (for, while), data type (int, double, char) For example: Problem using comparison: If (a>b) printf(“True”) else printf(“false”); Or import array from keyboard: It help us many difficult problems We can use many data type for data, int for integer, char for name, characters, … 1.3 Problem statement 1.3.1 Problem and solution 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 Problem: The problem of student information management is a difficult problem Manual management method has many disadvantages such as: • • • • Time consuming, complicated Information may be wrong and difficult to correct If the time is long, the document may be damaged Difficult for searching, statistics calculation We need to find a solution to this problem Solution: I think a student management program is a good choice Input information: name, ID, gender, score, … Output information: Name, ID, age, gender, score of all students, maximum score, minimum score, average score, result, grade, rank, … Advantages: • • • Enter information quickly and accurately Information is stored for a long time Easy search, calculation, statistics 1.3.2 Apply procedural programming for this problem Procedural programming is a good way to create this program To use many functions, I need to declare some necessary libraries such as , , , , … It helps me with calculations, data entry, … Next, I will declare a structure to collect all the required input information of a student, type int, float, char will be used for name, ID, points An interface would be necessary for any program but I need to get the number of students before I get started with the interface, initializing a variable with printf and scan will the job The while-do loop will be used, further initializing an array with the number of elements as the number of students Using multiple printf statement to print a menu of functions and use switch-case to select them The functions will be written below the main part, then they will be declared before the main section and used in each case to write the corresponding function Import and export functions: using for loop in combination with scanf, printf, gets statements Point functions: Using a for loop to “call” the combined values along with if, ifelse conditionals to compare, swap and printf to print the result Analysis 2.1 Data types and data structure To get around this, I used the data types: Type Data is used Reason to use Int ID, number of students, age, … Float Math, English, prog, average, … of scores Char Name, gender ID is an integer sequence and it represents student (for example: 200064), number of students (number of students to enter) and age is any integer starting from 1, age ranges from to 100 They are student scores, they are not purely integers but real numbers, because the input score is a real number so the printed score must also be a real number The student's name and gender are both a string of characters such as “Tung” or “male” Table 1: Data types A specialized format for organizing, processing, retrieving, and storing data is a data structure (Loshin and Lewis, 2021) Array: It allows me to store many elements, many types in one variable, these elements can be reference types Reason to use: Because my program has student information (ID, name, age, ) and has many students so need array to store them all in order This makes it easy to import and export information and use it for calculations Before calculating the GPA, I have to use the array to get them calculated If I don't use array, each variable will store value, if there are 10 students, I have to create 50 variables => This is terrible This structure is used for user to select function, these functions will be assigned with numbers from to When user selects any function, system will execute lines of code at case there For example, if is selected, it will execute the code in the exit function and exit the program Design 3.1 Use-case I will demonstrate the functions and interactions for the program through a use-case diagram Enter information of students Show information Max, Min, Average of grade Result of the course Teacher Rank of students Rating Exit Student management system 13 • • • • • • • Currently, the system is only available to teachers They can use all the main functions of the system The main functions are: Enter information of students Show information Result of the course Max, Min, Average of grade Rank of students Rating Exit 3.2 WBS • • WBS is a concept to describe the division of work objects with the aim of making work content transparent, identifying necessary tasks to achieve goals (Cohen, 2018) I built a WBS for this problem: WBS of my program 14 • My WBS has a few parts: - Enter information: Enter all the necessary student information such as ID, name, age, gender, scores For the functions to work properly, all information must be entered - Show information: Print ID, name, age, gender, scores of students - Find min, max, average of scores: It consists of lines of code that perform the main function of the program: Find the highest and lowest scores -> Print them Calculate average of students -> Print them - Find result, rank, rating: Find and print them 3.3 Flowcharts According to Ned Chapin, a graphical means of recording a sequence of activities is called a flowchart (Chapin, 2003) In IT, it is often called to rewrite the sequence and the way the program works I will draw and analyze this program as a flowchart Flowchart 1- Program overview 15 • • • • Here, the program takes the input value n (number of students) Next, get the input value o and array a[n] (used to select functions) Using switch with o, If the value of o is 1,2,3,4,5,6 (True), the program redirects to the corresponding function, if it receives False, it returns to the input step o If the value of o is 0, program will finish If o is others value, enter o We’ll get to each of the main functions: Function 1: Enter Information of student Flowchart 2- Function 16 • • • • • Start with the value i=0 Compare i

Ngày đăng: 22/03/2022, 18:17

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

Tài liệu liên quan