ASM1- PROG102- C PROGRAMING, Study Guides, Projects, Research of Distributed Programming and Computing

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.

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 04/11/2022

duongnguyen29
duongnguyen29 🇻🇳

5

(1)

1 document

1 / 22

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
STUDENT MANAGEMENT
PROGRAM
Procedural Programming
ASSIGNMENT 2
Learner’s name: Nguyễn Tuấn Dương
Student
ID: GCH200796
Class: GCH1006
Subject
code: PROG102
Assessor name:
Assignment due: 11-03-2022
Assignment submitted:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download ASM1- PROG102- C PROGRAMING and more Study Guides, Projects, Research Distributed Programming and Computing in PDF only on Docsity!

STUDENT MANAGEMENT

PROGRAM

Procedural Programming

ASSIGNMENT 2

Learner’s name: Nguyễn Tuấn Dương Student

ID:GCH

Class: GCH1006 Subject

code: PROG

Assessor name:

Assignment due: 11 - 03 - 2022

Assignment submitted:

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 Nguyễn Tuấn Dương^ Student ID (^) GCH 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 P4 P5 M3 M4 D

TABLE OF CONTENTS

  • I. Introduction. Contents
      1. Scenario
      1. Problem
      1. Solution
  • II. Implementation.
      1. Header file................................................................................................................................................
      1. Declare the variable Struct.
      1. void addStudent (struct student list[100] )
      1. void findMin(struct student list[100])
      1. Void findMax( struct student list[100])...............................................................................................
      1. int main()................................................................................................................................................
  • III. Program results.
      1. The program starts running
      1. Selection 1.
      1. Selection 2.
  • IV. Evaluation.
  • Conclusion.

I. 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. Problem A teacher wants to manage the grades of a class. You need to write a small application that meets his requirements. He needs to enter student information and store these in separate arrays. Then he needs to print all the student cards along with their grades. Finally, he needs to know which student has the highest score and the lowest score. Your program should have a menu based on the options above. When an option is taken, the program will return to the main menu so that he can choose another option. And there is an option to exit the program. 3. 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, calculate the entered data.

3. Declare the variable Struct. Structures in C Programming is used in cases where we must group dissimilar data types (int, float, char, etc.). The declarations in the Student struct function:

  • Char: used to declare a student's name, gender, and ID because these are all strings of characters or characters along with numbers. The variables name is provided with memory as 30 respectively.
  • Int: used to declare id because the student's id is a natural number.
  • Float : used to declare the grades of the subjects because the grades can be decimal.

4. void addStudent (struct student list[100] ) Explain: - Void: used because the student input function does not return a value. - Printf(): print out message lines for users to enter information. - Scanf(): read user numeric input. - Gets(): read user string input. - Fflush(stdin): clear cache. - The function will start with getting the number of students. The function will not stop until all the required information has been entered with a sufficient number of inputs. - Information such as "id" , "name" , "grade" will be saved to serve the following requests.

6. Void findMax( struct student list[100]) Explain: - Void: void is used to determine the biggest point value after being entered in the two previously entered voids. Thereby providing the results according to the user's demand - %o.2f : the result is taken with 2 decimal places after the comma. - The function will receive the first value and scan, if it encounters a bigger value, the function will receive that value and continue scanning. That process will continue until all values are scanned. The result will be the maximum value.

  • The function will make sure to progress until the last value is encountered.

7. int main().

Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.4. Line 93 - 95 Case2: Case uses the void findMax(data) capability. When finished, the case will stop with "break" Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.5. Line 96- 98 Case uses the void findMin(data) capability. When finished, the case will stop with "break" Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop 7.6. Line 99- 101 Break: the loop is Immediately terminated, and the program control resumes at the next Statement following the loop. Exit(0): Exit the program. 7.7. Default

III. Program results.

1. The program starts running 2. In case you choose options other than 1 and 0, the program will return to “Menu” In case you select other options greater than 6, the program will print an error message and ask to re-enter: “incorrect number. Choose again, please!” After that, the program will return to ”Menu”

Next, you will need to enter each student's information in the required form. After you have entered all the information of the students, the program will return to the “Menu”.

4. Selection 2. In case you choose option 2, the program will print out the information sheet of the students and return to the “Menu”

IV. Evaluation.

1. Program advantages. Let us begin by discussing the program's benefits. In general, the built software has satisfied the scenario's aims and, of course, the user's requirements (teachers). To begin, we solved the problem using procedural programming. To cope with which apps are, break down the burden into different functions. For testing and debugging, we employed the program's standalone features. As a result, the functions have been divided into parts. The design is scientifically presented, simple to comprehend, and simple to implement. Furthermore, the app contains a slew of features that are tailored to the user's needs. 2. Program limitations. Aside from the benefits listed above, the scheme has several flaws that must be addressed. The first is that for the application to operate, users will need to enter a lot of data, which may be quite inconvenient if the wrong data is entered. Second, if you don't correct the incorrect student data tomorrow, the application will continue to run and save the incorrect data until you correct it. Third, if you run the function to sort students' scores from high to low, the variables' locations will change, resulting in inaccurate information about the students with the highest and lowest scores if you run it again. Finally, if the user wishes to use the function to discover information about students by name, they must input all of the students' names that have been saved correctly, otherwise, the computer will state that no information about them was found.

3. Solution to the problem. To address the above problems, we have several rather effective and simple-to- implement remedies. Firstly, we may construct a separate function in the program called Modify student information. We may combine removing student information, modifying student information, and adding student information in this function. If a mistake is made, this method will make it easy to re-enter or modify student information. Secondly, after utilizing the student sort function, we may construct a piece of code that returns the values' original positions to avoid misplacement. Thirdly, when it comes to locating student information by name, we may create a program that searches just for continuous characters or a portion of the name. Searching will be faster and easier with this solution.