Download Programing Language 102 Asm1 and more Schemes and Mind Maps Law and Religion in the U.S. in PDF only on Docsity!
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 Received 2nd submission Student Name TRAN TIEN VAN Student ID GCH Class GCH1105 Assessor name PHAM DANH TUYEN 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 Nam Grading grid P4 P5 M3 M4 D
r Summative Feedback: Resubmission Feedback:
Grade: Assessor Signature: Date: Lecturer Signature:
INTRODUCTION
1) Scenario
- A math teacher wants to manage the grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, students’ grades and store this information into 2 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 the 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 the program.
2) Solution
Step 1: Define the variables and data types needed in the program. Step 2: Define different selection structures. Step 3: Define the iteration structure. Step 4: Divide the program into functions (subfunctions) and draw a hierarchy diagram to illustrate the structure of your program. Step 5: Create the program:
- There is a menu to display options.
- There is a function to enter student information.
- There is a function to print out the information of the students.
- There are functions to sort, compare to find out max or min grade
INPLEMENTATION
1) Header file
- stdio.h: Standard Input/Output functions The function used: int, char, float, for, do-while, switch-case, fflush(stdin), gets(), printf(), scanf().
2) Int Main ()
2.1) Line 3-10:
- Char name: used to declare a student's name because these are all strings of characters. The variables name are provided with memory as 128.
- Int ID: used to declare ID
- Float grade: used to declare the grades of the subjects and the grade can be decimal.
- Int main: the function will return an integer value. This value is the state of the program.
- Int n: variable that stores the value of the number of students in the class that the user entered.
- Int choice: variable that stores the value of the menu selection that the user entered.
- Int location: Student position with highest or lowest grade.
b) Case 2: Line 38-
- Printf(): print out the list. - Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop. c) Case 3: line 45-
- Float max = grade[0]: Value initialization, t’s consider that the first grade is max one and will have a return type of int
- For loop: to compare all the grade of students to find out the maxium.
- Printf: to printf out the maxium
- Float min = grade[0]: Value initialization, it’s consider that the first grade is in one and will have a return type of int.
- For loop: to compare all the grade of students to find out the minium.
- Printf: to printf out the minium. d) Case 4: line 60- Exit the program
- Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop. f) Default: line 63- - Default: handle exceptions when the conditional expression does not satisfy any of the cases. - Printf: printf out message lines for users to see the error choice - Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop. Frogram Resuilt
1) The program starts running
- At the beginning, the program will show you a sentence that is “Enter the number of students.
- In case you select other options that more than 4 or less than 1, the program will print an error message and menu again and ask to re-enter.
2) Section 2: Student list
- After the function finishes, the program will return to the main menu display
- It means “Show all the data”
- If you choose option 2, the program will print out the information sheet of the students.
3) Section 3: Statistical
- After the function finishes, the program will return to the main menu display
- It means “Find out the max and min grade”
- If you choose option 3, the program will print out the highest grade and lowest grade on the screen.
4) Section 4: Exit program
- After the function finishes, the program will return to the main menu display
- If you choose option 4, the program will print the message “BYE” and exit. Testing Results Testing Case ID (^) Testing Decription Test Steps Test data Expected Results Actual Results Evaluate 1 Enter the number student in the class Enter the correct datatype 3, 5, 9 Successful Successful Pass Enter the wrong datatype 5.2, -6, abc Error Error Pass 2 Enter the name of students and ID Enter the correct datatype Văn Successful Successful Pass Enter the correct datatype
Successful Successful Pass Enter the
After the course, I can relatively
understand what procedural
programming is, I can apply
procedural
programming to solve problems,
successfully understand how to
code a program and finally
created a
first small product that can run
After the course, I can relatively
understand what procedural
programming is, I can apply
procedural
programming to solve problems,
successfully understand how to
code a program and finally
created a
first small product that can run
After the course, I can relatively
understand what procedural
programming is, I can apply
procedural
programming to solve problems,
successfully understand how to
code a program and finally
created a
first small product that can run
After the course, I can relatively understand what procedural programming is, I can apply proceduralprogramming to solve problems, successfully understand how to code a program and finally created afirst small product that can run