Docsity

pro102-assignment-2-distinction, Assignments of Programming Languages

Toggle sidebar
bg1
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 Duc Long
Student ID
GCH210562
Class
GCH1106
Assessor name
Dinh Duc Manh
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
long
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
pf1f
pf20
pf21
pf22
pf23
pf24
pf25

Partial preview of the text

Download pro102-assignment-2-distinction and more Assignments Programming Languages 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 Duc Long Student ID GCH

Class GCH1106 Assessor name Dinh Duc Manh

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 long

Grading grid

P4 P5 M3 M4 D

❒ Summative Feedback: ❒ Resubmission Feedback:

Grade: Assessor Signature: Date:

Lecturer Signature:

  • ASSIGNMENT 2 FRONT SHEET
  • A- Introduction
  • B- Task 1: Code explanation and screenshot
    • I. Implementation (P4, M3)
        1. Libraries in my program.
        1. Data types in my program
      • 3 Function to create userLogin.
        1. Function to check whether a character is alphanumeric.
        1. Function to input integers and float.
        1. Function to enter student’s information.
        1. Function to enter and check number of student.
        1. Function to print captions student's list and print students.
        1. Function to show student's list.
        1. Function to arrange students by id.
        1. Function to add a new student in the list.......................................................................................................
        1. Function to search student by id.
        1. Function to search student grades.
        1. Function to find max and min.
        1. The main - menu function.
        1. Algorithms in my program:
        1. Rules for naming functions, variable names in my program
    • II. Program results (P4)..........................................................................................................................................
  • C- Task 2: Testing (P5, M4)
    • I. Testing
      • 1.Test userLogin
      • 2.Test id
      • 3.Test grade.........................................................................................................................................................
      • 4.Testing program in console screen
      • 5.Add a new student............................................................................................................................................
      • 6.Find student by id
      • 7.Find student by grade
      • 8.Find the highest score
      • 9.Find the highest score
      • 10.Show student’s list
      • 11.Exit program
    • II. Test plan:
        1. Test input:
        1. Test function:
        1. Overall evaluation of testing part....................................................................................................................
  • D- Task 3: Evaluation (D2)
    • Overall evaluation of the program.
      • 1.Strength:
      • 2.Weaknesses:
      • 3.Future improvements:
    • Evaluation procedural programming in my program..............................................................................................
      • Advantages:
      • Disadvantages:
      • Quote:
  • E- Conclusion:

A- Introduction

We live in a modern society where everything is modern and innovative. Every day, there is a

lot of innovation, especially in technology. When it comes to technology, we must admit that it has

permeated every aspect of our lives, from simple devices such as phones and computers to

complex programming applications.

In this assignment, I will discuss student mark management software, specifically how I can

use it, detailed explanations of its functions and characteristics, and finally an evaluation of the

functions and the overall program. In addition, I created 7 options in my program for users to

easily select, and each option has its own function and information to create a variety of programs.

These functions will assist the user in entering student information such as grade or id, and the

program will also assist the user in determining which students have the highest and lowest grades,

as well as statistics on how many students have good and bad grades.

  • char: is character type 3. Function to create userLogin.

I create a subfunction: userLogin(char username[],char password[])

In this case, I use the specifier to name the ASCII keyboard input keys:

I use while loop purpose when user enter wrong account can re-enter.

In password, I use getch(); to read characters one by one enter from the keyboard

Then I use "if else if" statements to check the condition:

+If "ch==enter" will finish entering password.

+If "ch==BKSP" will delete a character just entered from the keyboard

+If "ch==TAB" or "ch==SPACE" then continue typing

If it does not fall into the above cases, the asterisks will be printed

Next step I use the if else statement to check the username and password:

I use the string function “strcmp''(strcmp in library string.h) to compare two strings of username

and password. If username matches "duclong" and password matches "3907", the login is

successful and if incorrect, it will be re-entered.

And if there is no '.' then it is an integer

5. Function to input integers and float.

I create function inputInteger() and inputFloat to input integers and real numbers

● inputInteger():

I declare input array, read array and use while loop to input integer

condition in while: I call the function inputCheck(input) which I talked about in section 4

If the input character is not a number, it will be re-entered

● inputFloat():

I declare input array, read array and use while loop to input integer

condition in while: I call the function inputCheck(input) which I talked about in section 4

If the input character is not a number, it will be re-entered

● Note: +atoi function(in library stdlib.h): convert the header if possible in the string input to

an integer of type int. If the conversion is not possible, the value 0 will be returned. Any

leading whitespace character “input” will be ignored.

+atof function(in library stdlib.h): convert the beginning if possible in the string input to a

float. If the conversion is not possible, the value 0 will be returned. Any leading whitespace

character “input” will be ignored.

6. Function to enter student’s information.

I create a function: enterStudent() to enter student’s information.

In the loop, I call the enterStudent() function created in the section 6 and equalize the student at

position “i” and then check the condition.

8. Function to print captions student's list and print students.

I create 2 sub function: printCaptions() and printStudent(struct Student sv) to print caption of list

and print student’s information

9. Function to show student's list.

I create a function: printGroup(struct Student student[], int n)

Here I call the printCaption() function mentioned in item 8 to print the title of the list table.

I use a for loop to iterate

In the loop, I call the printStudent() function mentioned in section 8 to print out all the students in

the list entered from the keyboard.

10. Function to arrange students by id.

I create a function: arrangeStudents(struct Student list[], int n)

I use two nested for loops to survey from the beginning to the end and from the end to the

beginning.

In loop: I use if statement to check condition

if the student id at the front position is greater than the id of the student at the back position, the

two students will be swapped.

11. Function to add a new student in the list.

I create a sub function: addStudentToGroup(struct Student students[],int n, struct Student student)

I call enterStudent() (section 6) to enter new student information

if a new student is added to the list, the number of students will increase by one

In for, I use "if" statement to check: if the student’s grade entered is the same as the student’s

grade at position "i", show that student on the screen.

14. Function to find max and min.

I create 3 a function to find max and min:

searchMaxGrade(struct Student students[], int n),

searchMinGrade(struct Student students[], int n).

printStudentByGrade(struct Student students[], int n, float grade)

+Find student with the highest grade:

I use for loop to search

In loop i use if statement to check if condition:

max < students[i].grade then max = students[i].grade then returns max

+Find student with the lowest grade:

I use for loop to search

In loop i use if statement to check if condition:

min > students[i].grade then min = students[i].grade then returns min

+ Print the student with the same highest or lowest grade score:

Here I continue to call the function printCaptions() (section 8) to print the title

Then I use a for loop to print out the students with the same score

15. The main - menu function.

The main part of program is to display the main menu of the program this give user choices Leads

to subroutines that perform user choice. Thanks for "do....while" loop, after user choose 1 in 7

choices the program will repeat to help users choose another choices. If user want to quit program,

they just only choose choice 0. If the user enters a number that is not in the allowable amount, the

program displays an "invalid “error and forces the user to enter it again.

16. Algorithms in my program:

The bubble sort algorithm now sorts the sequence of numbers by repeating the task of swapping

two consecutive numbers if they are in the wrong order (in the case of ascending sort, the latter is