Docsity

1618 Assignment 1 - D pass, Essays (university) of Computer Science

Toggle sidebar
bg1
1
ASSIGNMENT 1 FRONT SHEET
Qualification
BTEC Level 5 HND Diploma in Computing
Unit number and
title
Unit 1: Programming
Submission date
Date Received 1st
submission
Re-submission
Date
Date Received 2nd
submission
Student Name
Ngo Tuan Anh
Student ID
GCH220570
Class
GCH1101
Assessor name
Student’s signature
Grading grid
P1
M1
D1
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
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b

Partial preview of the text

Download 1618 Assignment 1 - D pass and more Essays (university) Computer Science in PDF only on Docsity!

ASSIGNMENT 1 FRONT SHEET

Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Ngo Tuan Anh Student ID GCH Class GCH1101 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 P1 M1 D

❒ Summative Feedback: ❒ Resubmission Feedback: Grade: Assessor Signature: Date: Lecturer Signature:

  • I. INTRODUCTION..................................................................................................................................
      1. ALGORITHM
      • a. Definition
      • b. Properties of algorithms
      • c. Different types of algorithms
      • d. Why algorithm is important?
      • e. Object-oriented language (OOP)
      1. PROBLEM STATEMENT
      • a. Business problem
      • b. Applications of algorithm and OOP
  • II. ANALYSIS AND DESIGN...................................................................................................................
      1. ANALYSIS
      • a. Data Types
      • b. Data Structure
      • c. Conditional Statement
      • d. Loop statement
      1. DESIGN
      • a. Use-case diagram
      • b. WBS
      • c. Flowcharts
  • III. DEMONSTRATION
    • A. SOURCE CODE
      • i. Login
      • ii. Main
      • v. Display students’ records
      • vi. Add student’s records
      • vii. Update student’s records
      • viii. Delete student’s records
      • ix. Sort student’s grades
      • x. Save student’s records to a file
    • B. SCREENSHOTS
      • i. Login
      • ii. Menu options
      • iii. Add Students
      • iv. Display students’ records
      • v. Update student’s information
      • vi. Delete student
      • vii. Sort students by grades (descending order)
      • viii. Save the student records to a file
    • C. SOFTWARE DEVELOPMENT LIFE CYCLE
    • D. HOW THE SOURCE IS COMPILED AND RUN
  • IV. EVALUATION................................................................................................................................
    • A. MY SOLUTION
    • B. TEST CASES
  • BIBLIOGRAPHY

I. Introduction

1. Algorithm a. Definition An algorithm is a finite series of exact instructions used to solve a class of particular problems or carry out a calculation in mathematics and computer science (Anon., 2020). In its broadest meaning, is a set of instructions that guide a computer on how to turn a collection of world facts into helpful information. The information that is helpful to humans, robots, or other algorithms is derived from the facts, which are data. The process of doing laundry, the way we solve a long division problem, the ingredients for making a cake, and the operation of a search engine are all instances of algorithms. What might a list of instructions for baking a cake look like?

  • Warm the oven up.
  • Assemble the components
  • Count the components.
  • To prepare the batter, combine the ingredients.
  • Oil a pan.
  • Fill the pan with the batter.
  • Place the skillet in the oven.
  • Make a timer.
  • Take the pan out of the oven when the timer sounds.
  • Eating! Another example of an algorithm to solve a code problem is: Find the sum of two input numbers N and M. The procedure should be:
  • Enter the two numbers in the variables N and M.
  • Sum them and save the result in the variable sum.
  • Output the result.
  • Finiteness : After a finite number of steps, our algorithm must come to an end. There should never be an infinite loop or unlimited recursion.
  • Simple and Elegant : An algorithm should be easy to understand and implement. c. Different types of algorithms Based on the ideas that they employ to complete a task, algorithms are categorized. Even though there are numerous kinds of algorithms, the following are the most basic kinds:
  • Divide and conquer algorithms : break the problem down into smaller, related subproblems, solve those, then combine those solutions to solve the original problem.
  • Brute force algorithms: all potential solutions are tested until one is discovered to be adequate.
  • Randomized algorithms: use a random number at least once during the computation to find a solution to the problem.
  • Greedy algorithms: discover the best answer at the local level to find the best solution overall.
  • Recursive algorithms: solve the lowest and simplest version of a problem to then solve increasingly larger versions of the problem until the solution to the original problem is found.
  • Backtracking algorithms: Divide the problem into smaller problems that can each be tried to be addressed; however, if the desired answer is not obtained, travel backward in the problem until a path is found that pushes it forward.
  • Dynamic programming algorithms : divide a large problem into several smaller, more manageable subproblems, then solve each of those subproblems just once, saving the answer for later use rather than recalculating it. d. Why algorithm is important?

The capacity to identify precise methods to solve a problem, or algorithmic thinking, is essential in many different domains, including machine learning and artificial intelligence. We constantly employ algorithms and algorithmic thinking, even if we're not aware of it. People that use algorithmic thinking can dissect issues and visualize fixes as distinct processes. They must use structured thinking and reasoning skills to comprehend and use an algorithm. e. Object-oriented language (OOP) i. General concepts A programming paradigm called "Object-oriented programming" (OOP) is founded on the idea that "objects" can contain both code and data (Kindler & Krivy, 2011). Data can be found in the form of fields (sometimes called attributes or properties), while code can be found in the form of procedures (often known as methods). Objects frequently have procedures (or methods) connected to them that provide access to and control over the object's data fields. In this particular brand of OOP, the present object is typically identified by a special name like this or self. Computer programs are created using OOP by constructing them from objects that communicate with one another. For example, below is an illustration of an employee record where each person can be seen as an "object." Every employee has a name, age, and job title, so they can all be referred to as their "properties."

an object's blueprint. It outlines the object's characteristics, methods, and other features.

4. Inheritance and Composition The act of permitting one object to produce another is known as inheritance. The attributes, methods, and other features of another object can essentially be "inherited" by another object. The act of combining different objects to produce a brand-new, original object is known as composition. Programmers can essentially reuse the elements that are specific to other objects to construct new, original objects. iii. Compare to POP Procedural programming is a programming paradigm that uses a linear or top-down approach. It relies on procedures or subroutines to perform computations. (Techopedia 2015). In simpler words, programmers write a series of instructions involving the progress of splitting up lines of codes into a small set of variables, data structures, and subroutines. OOP POP Basic Definition OOP is object- oriented. POP is structure or procedure-oriented. Program Division The program is divided into objects. The program is divided into functions. Approach Bottom-Up approach Top-down approach Data Control Data in each object is controlled on its own. Every function has different data, so

there’s no control over it. Entity Linkage Object functions are linked through message passing. Parts of a program are linked through parameter passing. Expansion Adding new data and functions is easy. Expanding data and function is not easy. Inheritance Inheritance is supported in three modes: public, private & protected. Inheritance is not supported. Access control Access control is done with access modifiers. No access modifiers supported. Data Hiding Data can be hidden using Encapsulation. No data hiding. Data is accessible globally. Polymorphism Overloading functions, constructors, and operators are done. Overloading is not possible. Virtual classes or functions The virtual function appears during inheritance. No virtual classes or functions. Code Reusability The existing code can be reused. No code reusability.

2. Problem statement a. Business problem

and accounts (containing the username, and password), so object-oriented programming is a fit solution for creating and accessing the object details. Furthermore, there are various types of data such as student name (type string), student Id (type Integer), and grades (type float), that are needed to be stored and accessed through different methods. ÏFurthermore, there are various types of data such as student name (type string), student Id (type integer), and grades (type float) ... that need to be stored and accessed through different methods. Using global variables to store this information could help to reduce the duplication inside each function and all of the functions can access these variables. For example, the function accepts will receive the input from the teacher and store the student's records inside a list, and then the function display will get the data from the student's list, which is global, to display the records. To provide an interface for the teacher to choose the option to execute the program, a do-while loop statement and multiple print functions are necessary. Hence, to conclude, procedural programming is a well-suited solution for breaking down the programs into different sub-routines (suitable for different needed features that the Maths teacher wants), storing, managing variable sets to use globally through the program and loop and conditional statements for validation, display and get the inputs. II. Analysis and Design

1. Analysis a. Data Types No Name Type Purpose 1 Student Store student’s id, name, date of birth, grades, class 2 Account Store account’s username and password 3 userChoice String Store user’s menu choice

4 _students List List contains students’ record 5 i Integer Keep track of the index inside the students list 6 id Integer Store the index of the student needed to update or delete 7 isValidName, isValidGrade, isValidDob Boolean Variable to keep track of the validation result for input name, grades and date of birth b. Data Structure The program focuses on the use of a list as the record of students stores information from many students in an order of the input, or in the order of ascending after using the sorting function. Without the use of the array, each time a student is entered, we need to create another Student object to store that information, and it is not an optimized solution as when the input data gets bigger, a larger memory will be required to store all of those new students. c. Conditional Statement Executes different logic (actions) based on the condition that the developer defines (true or false).

  • ValidateDate : Multiple if statements to check if the format of the input string is a valid and the value of day, month and year is in valid range.

d. Loop statement Specific lines of code will be run a specified number of times inside this statement. There are three main statements inside a for loop: counter initialization, condition check, and increment or decrement operation to assign a new value to the counter variable. As the program will interact with each student one by one in the array, so a loop statement is necessary for this program.

  • Display the student's records : Loop through the student records s times, which s is the numbers of students in the records, and print out the student information in the same order as the teacher inputs.
  • Do-while statements continually let the user re-enter the choice to execute different functions until the user enters 0 to exit the program.

b. WBS Is a concept to describe the division of work objects to make work content transparent, and identify necessary tasks to achieve goals. (Cohen 2018) Through the main needed functions, the program has the following parts:

  • Enter student information : enter all of the student’s information, which are id, name, date of birth, class, and grade.
  • Display the record of students: print all of the above input information in a table format.
  • Update and Delete student’s information: by entering the student’s id, the program will find and update or delete the student according to the input id.
  • Search the student’s records: enter the student’s id and print out the student information.
  • Save the records to a file: write the students’ records to a txt file.
  • Login : enter the username and password, check the administrator account stored in a txt file, and return true or false. c. Flowcharts Shows the steps as boxes of various kinds, and their order by connecting the boxes with arrows. This diagrammatic representation illustrates a solution model to a given problem. (Wikipedia 2019) i. Login