Assignment 2- PROG102, Assignments of Computer Networks

Free to dowload...............

Typology: Assignments

2022/2023

Uploaded on 11/15/2021

Phan-Nhat-Linh-11
Phan-Nhat-Linh-11 🇻🇳

4.9

(108)

34 documents

1 / 30

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ASSIGNMENT 2 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and title
PROG102: Procedural Programming
Submission date
07/11/2021
Date Received 1st
submission
Re-submission Date
Date Received 2nd
submission
Student Name
Phan Nhat Linh
Student ID
GCD201635
Class
GCD0905
Assessor name
Phan Thanh Tra
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
Linh
Grading grid
P4
P5
M3
M4
D2
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e

Partial preview of the text

Download Assignment 2- PROG102 and more Assignments Computer Networks 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 07 /11/2021 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Phan Nhat Linh Student ID GCD Class GCD0905 Assessor name Phan Thanh Tra 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 Linh Grading grid P 4 P 5 M3 M4 D

 Summative Feedback:  Resubmission Feedback:

Grade: Assessor Signature: Date: Lecturer Signature:

Table of Contents

CHAPTER I: PROBLEM STATEMENT

1. Scenario

A math instructor is looking for a way to keep track of his or her students' grades. He requests your assistance in writing a simple program to do this. He must insert student IDs and grades into two different arrays (integer array for IDs and float array for grades). Following that, he must print all student IDs as well as their grades. Finally, he needs to know who has the best and worse grades. With the choices above, your program should be menu-driven. When a choice has been completed, the software should return to the main menu, allowing him to select another. An option to exit the software should be available. Figure 1 : Presenting

2. Objective reporting

The objective of the study is to create a program to help teachers and change all of their criteria. When he selects one option, the application returns him to the main menu, where he can pick another option. Additionally, the software will be able to escape. The paper then offers an illustrated guide to programming in general, with an emphasis on procedural programming. This study employs two selection structures and two repeating structures. These concepts may be used to handle problems such as returning to the menu after picking an item and allowing users to re-enter data if they don't meet the requirements. Finally, they make identifying students with the highest and lowest marks more easy.

3. Report outline

There are seven chapters in this study, as well as references. The following is a list of the chapters in this assignment:

❖ CHAPTER I: PROBLEM STATEMENT - Scenario introduction and report overview ❖ CHAPTER II: PROGRAM INTRODUCTION - Introducing in the program what I use ❖ CHAPTER III: IMPLEMENTATION (TASKS) - The tasks that the program must do ❖ CHAPTER IV: RESULTS (TASKS) - Actual results of those tasks. ❖ CHAPTER V: IMPLEMENTATION AND RESULTS (OPTION) - Options that the user can make. ❖ CHAPTER VI: TESTING - Checking the operation of the program. ❖ CHAPTER VII: EVALUATION AND CONCLUSION - Analysis, evaluation, solution and development in the program.

Figure 3 : If statement to choose the right options. If statement is used to avoid duplicate student ID. Figure 4 : If statement to avoid duplicate student ID. If statement to find the highest grade and the lowest grade. Figure 5 : If statement to find the highest grade Figure 6 : If statement to find the lowest grade If statement to find the students who have the highest grade the lowest grade. Figure 7 : If statement to find students who have highest grade Figure 8 : If statement to find students who have highest grade

3. Loop statement in the program

3.1 For This program uses a for loop to input and print student information, find the highest and lowest scores, and find the highest and lowest scorers. Figure 9 : For loop in the program 3.2 Do-while This program uses a do-while loop to execute options. After each option ends, the program will continue to execute until the user chooses option 5. Figure 10 : Do-while loop in the program. 3.3 While While loop to validate studentID and studentGrade data. Figure 11 : Validate studentID by while loop.

CHAPTER III: IMPLEMENTATION (TASKS)

1. Entering the number of students

Because in order to make the selections, we must enter the students to avoid the program error. Therefore, the input of the number of students will be done at the beginning of the program. It will help people not to forget to enter the number of students before making the selection. Figure 17 : Entering the number of student

2. Choosing options

The options will appear after entering the number of students and after each option ends. Instead of finishing each option the user has to scroll up to find the menu option, after finishing each option. It will appear thanks to the do-while loop. It makes it easy for users to visualize and choose the next options. Figure 18 : Choosing options The program will give an error when the option is greater than 5. Figure 19 : The program will report if option greater than 5 and less than 1

3. Entering student IDs and student grades

➢ We will use a for loop to enter student IDs and when we enter as many times as number of students the loop will stop.

➢ Because the user needs to enter the ID from 100 to 999, this program uses a while loop to report an error when the student ID is out of the range from 100 to 999. The program will say "Invalid ID. Please enter number from 100 to 999! " and the user will have to re-enter the student ID. ➢ Sometimes users will be confused, they may have the same student ID, so this program uses a while loop and declares the variable j<i. If studentID[i] = student[j], the program will say "ID already exists. Please re-enter: " and you will have to re-enter it. The loop will execute an infinite number of times and end if i = j. ➢ The program will force us to enter the score after each time we enter the student's ID. ➢ Student's grade will be from 0 to 10 thanks to the use of while loop. If you enter a number outside the range 0 to 10. The program will say "Invalid Grade. Please enter number from 0 to 10!" and you will have to re-enter. Figure 20 : Entering studentID and studentGrade

4. Printing all student IDs and grades

The program will use a for loop to print out all the IDs and grades. The score will be one decimal place with 2 decimal places thanks to %.2f. Figure 21 : Printing all student IDs and student grade

Figure 24 : Finding the lowest grade

8. Finding students who have lowest grade

We use a for loop to check all students' grades in the class. In the for loop we use the if statement. If the grade is equal to minGrade, the program will print the student's ID. The loop will continue until i = numberOfStudent. Figure 25 : Finding students who have lowest grade

9. Exiting the program

The program will continue to run when we enter another option 5. If we enter 5, the program will end.

Figure 26 : Exiting the program CHAPTER IV: RESULTS (TASKS)

1. Entering the number of students

We will enter the number of students, this is required at the start of the program. We will have to enter a number greater than 0. If we enter a number less than zero, the program will say "Invalid number of student. Please enter a number greater than 0" and we have to enter it again. For example, in this case, if we enter the number - 15, the program will report an error. And if we enter the number 30, the program will accept it. Figure 27 : Entering the number of student (result)

2. Choosing options

After entering the number of students, the program will appear an option menu for us to choose. The user will be forced to enter a number from 1 to 5 to execute the option. If the user enters a number other than 1 to 5, the program will say "Invalid menu option, please enter number from 1 to 5!" For example, if we enter - 2, the program will give an error and we will have to enter it again. The program will accept 2 because it is between 1 and 5.

Figure 29 : Entering student IDs and student grades(result)

4. Printing all student IDs and grades

The program will print out the IDs and points that we entered earlier in the order of input. For example, the program will print out the IDs and points of Figure 24. Figure 30 : Printing all student IDs and grades(result)

5. Finding the highest grade and students who have highest grade

First we will give a case where there is a list like Figure 26.

Figure 31 : All IDs and grade (example) First the program will find the highest grade then the program will find out the students who have the highest grade. Figure 32 : Finding the highest grade and students who have highest grade(result)

6. Finding the lowest grade and students who have lowest grade

First we will give a case where there is a list like Figure 26. First the program will find the lowest grade then the program will find out the students who have the lowest grade.