Docsity

Assignment 2 (P, M) - C Programming - Vo Minh Quoc, Essays (university) of C programming

Partial preview of the text

Download Assignment 2 (P, M) - C Programming - Vo Minh Quoc and more Essays (university) C programming in PDF only on Docsity!

ASSIGNMENT 2

Analyze and design a solution for procedural programming problem.

ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title PROG102: Procedural Programming Submission date 30/6/2021 Date Received 1st submission Re-submission Date 4/7/2021 Date Received 2nd submission Student Name Vo Minh Quoc Student ID GCD Class GCD0904 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 (^) Quoc Grading grid P 4 P 5 M3 M4 D

Table of Contents

  • 1 INTRODUCTION
    • 1.1 Problem
    • 1.2 Solution
  • 2 IMPLEMENTATION (P4, M3)
    • 2.1 Structure of program
    • 2.2 Function and how each function is used in program
    • 2.3 Important algorithms in program
  • 3 PROGRAM RESULTS (P4)...............................................................................................................................
  • 4 TESTING (P5, M4)
    • 4.1 Test plan:.....................................................................................................................................................
    • 4.2 Test log
  • 5 EVALUATION (D2)
    • 5.1 Evaluate the program, state lessons learned, and future improvements.
    • (advantages, disadvantage, difficulties) 5.2 Evaluate how procedural programming is applied in (Anonymous, n.d) (Bhatia, n.d) program
  • 6 Bibliography
1 INTRODUCTION

1.1 Problem

  • A math teacher wants to manage grades of a class. He asks you to help him to write a small application to do that. He needs to enter student IDs, student’s grades and store these 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 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. 1.2 Solution
  • I wrote the program by using procedural programming in C language. This program can manage grades and ID corresponding to grades. The teacher can be input, output information, output highest and lowest grade of students. Figure 1. Case diagram of the program 2 IMPLEMENTATION (P4, M3) 2.1 Structure of program
  • My program include 4 part:
  • Declaring libraries used in program. o <stdio.h>: Provides the core of the typing capabilities in C. o <stdlib.h> : Used to perform a variety of operations, including transformations, pseudo-random numbers, memory allocation, process control, environment, signaling, search, and sequencing. o <string.h> : To adjust a variety of character ranges. Figure 2. Declare libraries
  • Function “outputInformation” helps the math teacher to display the grade corresponding to the ID which are stored previously from function “inputInformation” via “do…while” loop. Figure 6. Function output information of students
  • Function “main()” is the menu option used for outputting five choices including:
    • Exit program.
    • Input information of student.
    • Output information of student.
    • Display IDs have highest grade.
    • Display IDs have lowest grade.
    • Re-enter the number of students if you enter wrong. And when the math teacher starts the program, the first thing he/she has to do is enter the number of students. This function uses “do…while” loop, “if” statement, switch statement and for loop. Figure 7. Function menu option of program

Figure 8. Function menu option of program Figure 9 .Function menu option of program.

Figure 11. Flowchart of finding the highest grade

  • Find the lowest grade of student:

Figure 12. Flowchart of finding lowest grade.

  • Output ID and grade of students: Figure 16. Choice 2
  • Find the ID has the highest grade: Figure 17. Choice 3
  • Find the ID has the lowest grade: Figure 18 .Choice 4
  • Re-enter the number of students: Figure 19. Choice 5.
4 TESTING (P5, M4)

4.1 Test plan:

TES
T P
LAN

Test case ID Test case Plan Start date End date Estimated Efforts(Hrs/day) 1 The number of student (int a) (3<a<50) Enter valid data and invalid data into the number of student 30/06/2021 30/06/2021 1 Hour 2 Grade of students (float grade[100]) Range: 0 to 10 Enter valid data and invalid data into the number of student 3 ID of students (int ID[100]) Enter valid data and invalid data into the number of student 4 Menu option. Range: 0 to 5 Enter valid data and invalid data into the number of student

Integer inside the condition( to 50) Accepted Accepted Pass Integer outside the condition Unaccepted Unaccepted Pass Decimal: 1.1, 1.2, … Error Error Pass

Grade of students (float grade[100]) Range: 0 to 10 Letter: A, b, c, … Error Error Pass Special character: !, @, ?, … Error Error Pass

Special character: !, @, ?, … Error Error Pass Integer: 0, 1, 2,… Accepted Accepted Pass Duplicated data Unaccepted Unaccepted Pass

Decimal: 1.1, 1.2,… Error Error Pass 4 Menu option. Range: 0 to 5 Letter: A, b, c, … Error Accepted Fail Special character: !, @, ?, … Error Accepted Fail