Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Assignment 2 subject Programming, Exercises for Computer Science, Exercises of Programming Languages

Assignment 2 subject Programming, Exercises for Computer Science

Typology: Exercises

2021/2022

Uploaded on 03/14/2022

hien-tran-6523
hien-tran-6523 🇻🇳

4.7

(35)

23 documents

1 / 27

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
Higher National in Computing
Unit 1: Programming
ASSIGNMENT 2
Learner’s name: Tran Quang
Hien ID: GCS210109
Class: GCS1003A
Subject code: 1618
Assignment due: Assignment submitted:
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b

Partial preview of the text

Download Assignment 2 subject Programming, Exercises for Computer Science and more Exercises Programming Languages in PDF only on Docsity!

Higher National in Computing

Unit 1: Programming

ASSIGNMENT 2

Learner’s name: Tran Quang HienID: GCS Class: GCS1003A Subject code: 1618 Assignment due: Assignment submitted:

ASSIGNMENT 2 FRONT SHEET Qualification BTEC Level 5 HND Diploma in Computing Unit number and title Unit 1: Programming Submission date 05 /03/2022 Date Received 1st submission Re-submission Date Date Received 2nd submission Student Name Tran Quang Hien Student ID GCS Class GCS1003A Assessor name Nguyen Tuan Dang 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 P2 P3 P4 P5 M2 M3 M4 D2 D3 D

Assignment Brief 2 (RQF)

Higher National Certificate/Diploma in Computing

Student Name/ID Number: Tran^ Quang Hien Unit Number and Title: Unit 1: Programming Academic Year: 2021 – 2022 Unit Assessor: Nguyen Tuan Dang Assignment Title: Application development with IDE Issue Date: Submission Date: 05/03/ Internal Verifier Name: Date: Submission Format: Format: ● The submission is in the form of an individual written report. This should be written in a concise, formal business style using single spacing and font size 12. You are required to make use of headings, paragraphs and subsections as appropriate, and all work must be supported with research and referenced using the Harvard referencing system. Please also provide a bibliography using the Harvard referencing system. Submission ● Students are compulsory to submit the assignment in due date and in a way requested by the Tutor. ● The form of submission will be a soft copy posted on http://cms.greenwich.edu.vn/. ● Remember to convert the word file into PDF file before the submission on CMS. Note: ● The individual Assignment must be your own work, and not copied by or from another student. ● If you use ideas, quotes or data (such as diagrams) from books, journals or other sources, you must reference your sources, using the Harvard style. ● Make sure that you understand and follow the guidelines to avoid plagiarism. Failure to comply this requirement will result in a failed assignment. Unit Learning Outcomes:

LO2 Explain the characteristics of procedural, object-oriented and event-driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE) LO3 Implement basic algorithms in code using an IDE LO4 Determine the debugging process and explain the importance of a coding standard Assignment Brief and Guidance: Assignment scenario Scenario : You have applied for a post as a trainee with a software development company and have been invited for an interview. You have been passed the presentation to demonstrate your problem solving and basic programming skills. Now you are given a more challenge task to create a fully working, secure application that has been developed using an IDE and adheres to coding standards for a detailed business problem. Tasks You will discuss a suitable problem with your mentor and list the user requirements before designing, implementing (coding) and testing a solution. You will create a report that should include: ● Introduction to your program (list of requirements and screenshots of program) ● Explain some of programming paradigms. Evaluate why and how your program use these (or some of) paradigms. ● Explain the common features of an IDE should have and evidence of how the IDE was used to manage the development of your code. ● An evaluation of developing applications using an IDE versus developing an application without using an IDE. ● An explanation and evaluation of the debugging process in the IDE used and how it helped with development. ● An explanation and evaluation of coding standards used in your program and the benefits to organisations of using them. The working application produced must also be demonstrated together with the presentation. Case Studies You can choose one of following case studies to implement Hotel Management System: A Hotel Management System is a software built to handle all online hotel activities easily and safely. This System will give the hotel management power and flexibility to manage the entire system from a single online portal. The system allows the manager to keep track of all the available rooms in the system as well as to book rooms and generate bills.

  1. The system should support the booking of different room types like standard, deluxe, family suite, etc.
  2. Guests should be able to search the room inventory and book any available room.
  3. The system should be able to retrieve information, such as who booked a particular room, or what rooms were booked by a specific customer.

Learning Outcomes and Assessment Criteria (Assignment 2): Learning Outcome Pass Merit Distinction LO2 P2 Give explanations M2 Analyse the D2 Critically evaluate of what procedural, common features that the source code of an object-oriented and a developer has access application which event-driven to in an IDE. implements the paradigms are; their programming characteristics and the paradigms, in terms of relationship between the code structure and them. characteristics. LO3 P3 Write a program that implements an algorithm using an IDE. M3 Use the IDE to manage the development process of the program. D3 Evaluate the use of an IDE for the development of applications contrasted with not using an IDE. LO4 (^) P4 Explain the debugging process and explain the debugging facilities available in the IDE. M4 Evaluate how the debugging process can be used to help develop more secure, robust applications. D4 Critically evaluate why a coding standard is necessary in a team as well as for the individual. P5 Outline the coding standard you have used in your code.

Table of Contents

3 .3.3 How the debugging process can be used to help develop more secure, robust applications ............................................................................................................................................... 14

ASSIGNMENT 1 ANSWER

Introduction In Assignment 1, I presented the definition of an algorithm, posed a tiny issue, and then used procedural programming to solve it in C#. In Assignment 2, I'll offer you another issue to tackle using the Integrated Development Environment (IDE) and a combination of procedural programming, object-oriented programming, and event-driven programming. Furthermore, I will discuss the debugging process as well as the significance of code standards and naming conventions. My project will be divided into four chapters, as follows: Task 1: Introduction to your program Task 2: Explain programming paradigms Task 3: IDE features Task 4: Design and Implementation Task 1: Introduction to your program 1 .1 Overview of the problem 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. One piece of information about the package: product ID, product name, weight, destination. If any of the above data is missing, the application will display a notice asking the user to fill it in. 1 .2 List out application’s requirements The software will need to meet the following requirements based on the problem:

  • Have to remember each student’s scores.
  • Can print out the student’s IDs and their scores.
  • Can find out which students have the highest and lowest score.
  • Must have a menu with options for each task Task 2: Explain programming paradigms 2 .1 Procedural Programming 2 .1.1 Definition The first basic programming paradigm that a new programmer will learn is procedural programming (POP). Procedural programming is essentially code that tells a device how to perform a task in a specific order. The control flow organization of the software is depicted in this flowchart. If a program is too large, procedural programming breaks it into functions. A function is essentially a subroutine that contains a set of instructions to be followed. In a word, procedural programming is the process of writing a set of instructions for the computer to follow in order to execute the task specified by the programmer.

Figure 1 - How Procedural programming runs the program 2 .1.2 Characteristics Procedural programming languages make it easy for developers or programmers to build large application programs by dividing them into subroutines also known as functions. Procedural programming implements a top-down approach, i.e., a programming paradigm. In addition, procedural programming breaks down the application program into data structures, variables, and subroutines that can be easily used by users. Procedural programming languages or codes are executed very quickly because they take up fewer memory resources. Furthermore, procedural programming languages allow developers to provide a greater degree of control as well as portable source code. Therefore, it can be said that procedural programming can be used to evaluate and analyze all the distinguishing areas of our lives. In addition, procedural programming provides better solutions for complex programs.

  • Methods: Methods are used to store and save a set of instructions that a procedure is executed in a procedural programming language. It's also used in programming languages with access control.
  • Function: Small procedures or functions, often known as readily manageable functions, are used to break down a huge program. This helps to enhance the readability and maintainability of the code by reducing the number of duplicate statements in the program. Functions can also be broken down into modules that can be reused in other projects. 2 .2 Object-oriented programming 2 .2.1 Definition Object-oriented programming (OOP) is a programming paradigm that practically every developer will encounter at some time in their career. For many programmers, OOP is the most frequent programming paradigm, and it is taught as the conventional style of writing. We're going to break down the principles of what defines an object-oriented program today so you can start applying it in your own projects and

Figure 2- Event-driven programming

Source: https://www.boost.org/doc/libs/1_62_0/libs/coroutine2/doc/html/coroutine2/motivation.html 2 .3.2 Characteristics

  • Service-Oriented The service focus is a significant component in event-driven programming that is used to construct programs for services, and it does not slow down the computer. Service orientation takes up just a small portion of the lifespan of a computer's control, and most services execute inside the framework of the operating system (Kolesnikava, 2021).
  • Time-Driven The time impact of a dynamic set event can be a pattern. It's typically considered a fundamental tool that will work for your period of time, whether it once, once a week, or once a month, from executing code to trigger time. This makes sense given the setting prior to action (Kolesnikava, 2021).
  • Triggering Mechanisms In event-driven coding, trigger functions determine what code should be executed when a specific event happens. When programmers can pinpoint the specific event that occurred, they utilize these functions to choose the event handler to employ for the function (Kolesnikava, 2021). Events The mouse, keyboard, and interface are all events that must be triggered during this application. This means that the user will have to interact with an item over the course of the application, such as clicking a button with a mouse, selecting a button with a keyboard, and so on (Kolesnikava, 2021).
  • Programming Simplicity and Ease of Development Procedural and object-oriented programming is substantially more difficult to program than event-driven programming. For example, you'll be able to choose a button and place it on a form, as well as write code for it. Users may also easily insert a piece of pre-written code into an existing application using event-driven development(Kolesnikava, 2021). 2 .4 The relationship between procedural programming, object-oriented programming, and event- driven programming My own thoughts on the relationship between the three programming approaches are as follows, based on what I've learned through the aforementioned three methods:

You define a program and its subroutines as a series of steps when you program. Declarative programs, on the other hand, intend to explain the result without mentioning the methods used to computerize it, but rather with a description or representation of the desired outcome. Object-oriented programming techniques address these issues. Object-oriented programming (OOP) is a method of grouping code into classes of component objects that work together to solve a problem. Encapsulation, inheritance, abstraction, and polymorphism are four properties of object-oriented programming. The objects in the class, on the other hand, must still adhere to procedural programming. These two programming approaches, however, continue to execute on the terminal interface (black background and write font). That's why event-driven programming was created to make it easier for programmers to capture events on the Win-Form platform. There will be numerous events, but the "click" event will continue to be the most common. The basic event loop is given by the underlying system, while event-driven programming relies on procedural methods for event handling. You'll save time and effort by not having to write your own event loop, and you'll be able to make use of the many libraries that already operate with the system's event loop. Event-based programs are frequently, but not always, written in an object-oriented style. Task 3: IDE features 3 .1 Definition An integrated development environment (IDE) is application development software that combines many developer tools into a single graphical user interface (GUI) (Anon., n.d.). An IDE usually consists of the following components:

  • Source code editor: A text editor with capabilities such as syntax highlighting with visual cues, language- specific auto-completion, and bug checking as code is typed to aid in developing software code (Anon., n.d.).
  • Local build automation: Utilities that automate simple, repeated activities such as converting computer ASCII text files into code, packaging code, and performing automated tests as part of building an area build of the product to be utilized by the developer (Anon., n.d.).
  • Debugger: A software for testing other programs that display the state of a defect in the source code visually (Anon., n.d.). 3 .2 Features of IDE with illustrations
  • Text editor: Almost every integrated development environment (IDE) will have a text editor for creating and modifying source code. Although some tools feature visual components for dragging and dropping UI elements, the majority have a simple interface with syntax highlighting for each language (Walker, 2018).
  • Debugger: Users can use debugging tools to help them find and fix issues in ASCII text files. They frequently mimic real-world events to ensure that the application meets their needs in terms of functionality and performance (Walker, 2018).

When the application first starts, it will display a window where I may add data to begin the process of running the code by texting the "Add" button. The first red dot will light up when you begin checking the code. You may now hit F11 to exit. This is the "Step Into" function, which improves the application's execution one statement at a time. The debugger will interrupt the first statement to be performed when you start the application with F11. This is the function that will let you comprehend the code execution in the most thorough way possible. During debugging, if you feel a piece of code is okay but don't want to double-check it, you can hit F10. This is the "Step Over" feature, which allows you to skip over code that you don't care about. This allows you to easily get to the code that most interests you. After you've double-checked that your software is working properly. You may leave the debugger by pressing Shift + F5. That's how the debugging process works in Visual Studio. So, what functions are available in the debugging process in Visual Studio to assist programmers to understand the code more deeply? Here are a few functions that Visual Studio makes available to programmers:

  • Run to cursor Select Run to Cursor from the context menu when you right-click on a line of code in your program. This step initiates debugging and places a breakpoint on the currently active line of code. If you've set breakpoints, the debugger will halt when it reaches the first one. F5 until you reach the line of code where you choose Run to the cursor.
  • Edit code while executing You can modify your code in the midst of a debugging session in Visual Studio and keep debugging. To utilize this functionality, pause the debugger and click on your code with the cursor, make changes, and then hit F10 to resume debugging.
  • Examine the call stack The Call Stack pane displays the method and function calls in chronological sequence. This is a fantastic technique to test and understand an application's execution flow. 3 .3.3 How the debugging process can be used to help develop more secure, robust applications Debugging is a critical activity for a developer since it helps to reduce the number of mistakes that might occur in software. Debugging in Visual Studio 20 22 will assist developers in identifying flaws using capabilities such as: •Recognize when a mistake occurs. •Look in windows like Autos and Local to figure out what's causing the problem. •Run a quick test by ignoring tried-and-true procedures. •When debugging, set breakpoints. •Modify the code while debugging I demonstrated how to utilize the debugging tools and thorough debugging facility in Visual Studio 20 22 , which is a very strong and vital element in programming. Debugging, in brief, aids programmers in creating safer and more streamlined software. This is a platform for programmers to help them save time, increase productivity, and grow their programs. 3 .4 An evaluation of developing applications using an IDE versus developing an application without using an IDE
  • Using IDE

The IDE makes developing applications easier and more convenient for you.. Even if you don't have an IDE, you can still create source code since all you need is the proper compiler (compiler) for that programming language to run the source code. When you're building apps using Visual Studio 2019, the IDE features a built-in compiler or interpreter that enables you to run code directly.

  • Don’t use IDE If you're writing a program in Microsoft Word, you'll need to save it in the appropriate file format for the language you're using. Then, using the compiler program for that language, execute the code again. It makes me feel uneasy just thinking about it. Can you learn the whole command syntax in order to confidently program without using an IDE? Furthermore, avoiding grammatical mistakes while developing code is really tough. And how long would it take you to detect the problem if your software is 1000 lines lengthy? Here's an example of writing code in Word. Task 4: Design and Implementation 4 .1 Menu design I drew up a basic menu design that includes how many features the software requires as well as a way to exit the application if necessary. Figure 3: Menu design

This step is required for the system to generate appropriate storage spaces for our variables.

  • The first function I wrote is the Input Names & Scores function(b) (b) This function allows the user to input the IDs and individual scores of each student. The number of pupils displayed on the screen will be in numerical sequence and will be determined by the number of students recorded by the user.
  • The next function is the OutputNames&Scores function(c) (c) This function is used to display the IDs of the students as well as their grades.

This function will generate a list of student IDs and scores in the order given by the user.

  • The next 2 functions are made to determine which scores are the highest and lowest, they also pinpoint the ID of the students who possessed those scores(d1) (d2) (d1) (d2) To compare the provided scores, I use "for " to create a loop. These functions work by taking the greatest (or lowest) score as the first input, then comparing that score to the second, and so on. When it meets a higher (or lower) score than itself, the highest (or lowest) score