Docsity

2021 programming assignment, Assignments of Programming Languages

Toggle sidebar
bg1
Contents
Acknnowledgement .......................................................................... Error! Bookmark not defined.
Introduction .................................................................................................................................... 1
1.1 Define what an algorithm is. Give a simple example of an algorithm using a technique that
you’ve learnt/know to express algorithms .................................................................................... 2
Simple example for an algorithm using flow chart ........................................................................ 3
1.2 Briefly describe the process of building a software application (i.e. the phases of the SDLC –
Software Development Life Cycle) ................................................................................................. 5
1.3 Explain the roles of the Pre-processor, Compiler, Linker & Interpreter and describe the
process of programme execution (steps taken from writing code to execution) of a
programming language of your choice (i.e. Java) .......................................................................... 7
2.1 Explain procedural, object oriented and event driven programming paradigms. Your
explanations should also include the characteristics of each ...................................................... 10
2.2 Describe the relationship between procedural, object oriented and event driven paradigms.
28 .................................................................................................................................................. 12
2.3 Explain what an Integrated development environment (IDE) is. Give three examples of your
choice ............................................................................................................................................ 13
2.3 Do a comparison of the features of the IDEs you’ve mentioned in 2.3. Analyze the common
features that a developer has access to in all these IDEs ............................................................ 14
NetBeans vs Eclipse ...................................................................................................................... 15
4.1 Explain how debugging is carried out using the IDE that you used for developing your
application (the debugging process). Describe the debugging facilities available in the IDE you
used. 42
4.2 Outline the coding standards you have used when developing the above application.......42
Introduction
A programme is a set of instructions that tell the computer to do various things; sometimes
the instruction it has to perform depends on what happened when it performed a previous
instruction. This section gives an overview of the two main ways in which you can give these
instructions, or “commands” as they are usually called. One way uses an interpreter, the other
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 2021 programming assignment and more Assignments Programming Languages in PDF only on Docsity!

Contents

Acknnowledgement .......................................................................... Error! Bookmark not defined. Introduction .................................................................................................................................... 1 1.1 Define what an algorithm is. Give a simple example of an algorithm using a technique that you’ve learnt/know to express algorithms .................................................................................... 2 Simple example for an algorithm using flow chart ........................................................................ 3 1.2 Briefly describe the process of building a software application (i.e. the phases of the SDLC – Software Development Life Cycle) ................................................................................................. 5 1.3 Explain the roles of the Pre-processor, Compiler, Linker & Interpreter and describe the process of programme execution (steps taken from writing code to execution) of a programming language of your choice (i.e. Java) .......................................................................... 7 2.1 Explain procedural, object oriented and event driven programming paradigms. Your explanations should also include the characteristics of each ...................................................... 10 2.2 Describe the relationship between procedural, object oriented and event driven paradigms. 28 .................................................................................................................................................. 12 2.3 Explain what an Integrated development environment (IDE) is. Give three examples of your choice............................................................................................................................................ 13 2.3 Do a comparison of the features of the IDEs you’ve mentioned in 2.3. Analyze the common features that a developer has access to in all these IDEs ............................................................ 14 NetBeans vs Eclipse ...................................................................................................................... 15 4.1 Explain how debugging is carried out using the IDE that you used for developing your application (the debugging process). Describe the debugging facilities available in the IDE you used. 42 4.2 Outline the coding standards you have used when developing the above application.......

Introduction

A programme is a set of instructions that tell the computer to do various things; sometimes the instruction it has to perform depends on what happened when it performed a previous instruction. This section gives an overview of the two main ways in which you can give these instructions, or “commands” as they are usually called. One way uses an interpreter, the other

a compiler. As human languages are too difficult for a computer to understand in an unambiguous way, commands are usually written in one or other languages specially designed for the purpose. In this assignment at the beginning we are going to explain about algorithms and the process of a programming application. Then we have to explain the characteristics of procedural, objectoriented and event-driven programming, conduct an analysis of a suitable IDE and implement basic algorithms in code using IDE. At the end of this assignment we have to determine the debugging process and explain the importance of a coding standard.

Task 01

1.1 Define what an algorithm is. Give a simple example of an

algorithm using a technique that you’ve learnt/know to

express

algorithms (i.e. a pseudocode/ flow chart).

Programming is the process of taking an algorithm and encoding it into a notation, a programming language, so that it can be executed by a computer. Even though many programming languages and many different types of computers exist, the important first step is the need to have the solution. Without an algorithm there can be no program. Computer science is not the study of programming. Programming, however, is a vital part of what a computer scientist does. Programming is often the way that we create a representation for our solutions. Therefore, this language representation and the process of creating it becomes a fundamental part of the discipline. Algorithms describe the solution to a problem in terms of the data needed to represent the problem instance and the set of steps necessary to produce the intended result. Programming languages must provide a notational way to represent both the process and the data. To this end, languages offer control constructs and data types.

1.2 Briefly describe the process of building a software application

(i.e. the phases of the SDLC – Software Development Life Cycle)

The process of software development services goes to through a series stages in step wise fashion that almost every developing company follows. Known as the software development life cycle, these six steps include planning, analysis, design, development and implementation, testing and deployment and maintenance. Let’s go ahead and see each of these steps to know how the perfect software is developed.

  1. Planning : without the good plan, calculating the strength and weaknesses of the project, development of software is meaningless. Planning kicks off a project flawlessly and affects its progress positively.
  2. Analysis : this step about analyzing the performance of the software at various stages and making notes on additional requirements. Analysis is very important to proceed further to the next step.
  3. Design : once the analysis is complete, the step of designing takes over, which is basically building the architecture of the project. This step will remove possible flaws by setting a standard and attempting to stick to it.
  4. Development and implementation: the actual task of developing the software starts here with data recording going on in the background. Once the software is developed, the step of implementation comes in where the product goes through a pilot study to see if it’s functioning properly.
  5. Testing: the testing stage assesses the software for errors and documentation bugs if there are any.

1.3 Explain the roles of the Pre-processor, Compiler, Linker &

Interpreter and describe the process of programe execution

(steps taken from writing code to execution) of a

programming language of your choice (i.e. Java)

Pre-processor The pre-processor is a macro processor that is used automatically by the C compiler to transform your program before actual compilation (Preprocessor directives are executed before compilation.). It is called a macro processor because it allows you to define macros, which are brief abbreviations for longer constructs. A macro is a segment of code which is replaced by the value of macro. Macro is defined by directive. Compiler A compiler is a computer program that transforms code written in a high-level programming language into the machine code. It is a program which translates the human-readable code to a language a computer processor understands (binary 1 and 0 bits). The computer processes the machine code to perform the corresponding taasks. A compiler should comply with the syntax rule of that programming language in which it is written. However, the compiler is only a program and cannot fix errors found in that program. So, if you make a mistake, you need to make changes in the syntax of your program. Otherwise, it will not compile. Linker and Interpreter An interpreter is a computer program, which coverts each high-level program statement into the machine code. This includes source code, pre-compiled code, and scripts. Both compiler and interpreters do the same job which is converting higher level programming language to machine code. However, a compiler will convert the code into machine code (create an exe) before program run. Interpreters convert code into machine code when the program is run.

Linker In high level languages, some inbuilt header files or libraries are keep. These libraries are predefined and these contain basic functions that are essential for execution the program. These functions are connected to the libraries by a program known as Linker. If linker doesn't realize a library of a operate then it informs to compiler and so compiler generates an error. The compiler mechanically invokes the linker because the last step in compilation a program. Not built in libraries that also links the user defined functions to the user defined libraries. Sometimes an extended program is divided into smaller subprograms known as modules. And these modules should be combined to execute the program. The method of combining the modules is finished by the linker. Process of programme execution (Java) First, the source ‘.java’ file is passed through the compiler, which then encodes the source code into a machine independent encoding, known as Bytecode. The content of each class contained in the source file is stored in a separate ‘.class’ file. While converting the source code into the bytecode, the compiler follows the following steps: Parse: Reads a set of *.java source files and maps the resulting token sequence into AST (Abstract Syntax Tree)-Nodes. Enter: Enters symbols for the definitions into the symbol table. Process annotations: If Requested, processes annotations found in the specified compilation units. Attribute: Attributes the Syntax trees. This step includes name resolution, type checking and constant folding. Flow: Performs dataflow analysis on the trees from the previous step. This includes checks for assignments and reachability. Desugar: Rewrites the AST and translates away some syntactic sugar. Generate: Generates ‘.Class’ files

Task 02

2.1 Explain procedural, object oriented and event driven

programming paradigms. Your explanations should also include

the characteristics of each.

Procedural programming In procedural programming, a program consists of data and modules/procedures that operate on the data. The two are treated as separate entities. In the object-oriented programming (OOP) paradigm, however, a program is built from objects. An object is an instance of a class, which is an encapsulation of data (called fields) and the procedures (called methods) that manipulate them. In most, but not all, cases, the fields can only be accessed or modified through the methods. An object therefore is like a miniature program or a self-contained component, which makes the OOP approach more modularized and thus easier to maintain and extend. Another type of programming paradigm that procedural programming can be contrasted with is event-driven programming. In this approach, procedures are called/executed only in response to events, which may include mouse clicks, keyboard press, attaching or removing a device, arrival of data from an external source, etc. As these events are unpredictable, the procedures that handle them cannot be executed linearly as is the case with procedural programming. Characteristics of Procedural oriented programming: It focuses on process rather than data.

  • It takes a problem as a sequence of things to be done such as reading, calculating and printing. Hence, a number of functions are written to solve a problem.
  • A program is divided into a number of functions and each function has clearly defined purpose.
  • Most of the functions share global data.
  • Data moves openly around the system from function to function.

Object oriented programming Object-oriented programming (OOP) refers to a type of computer programming (software design) in which programmers define the data type of a data structure, and also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an object that includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects. Some key features of the Object-Oriented programming are:

  • Emphasis on data rather than procedure
  • Programs are divided into entities known as objects
  • Data Structures are designed such that they characterize objects
  • Functions that operate on data of an object are tied together in data structures
  • Data is hidden and cannot be accessed by external functions
  • Objects communicate with each other through functions- New data and functions can be easily added whenever necessary - Follows bottom up design in program design. Event driven programming Event-driven programming known as a computer programming paradigm that used the occurrence of events to determine the control flow of the program. This type of application is designed to detect events as they occur, and use an appropriate event-handling procedure to deal with it, which normally use a callback function or method. Theoretically, event-driven style of programming is supported in all programming languages, but they may different in the way of implement it, for example, it’s easier to implement in languages that provide high-level abstractions, such as closures. Besides, for other programming environments such as Adobe Flash, they are specifically tailored for triggering program code by events. Generally, there is a main loop in an event-driven application that used to listen for events and triggers a callback function when there are events is detected.

but not always. These three categories are thus not related strictly hierarchically, but in common usage they are mostly nested within one another.

2.3 Explain what an Integrated development environment (IDE) is.

Give three examples of your choice.

An Integrated Development Environment (IDE) is an application that facilitates application development. In general, an IDE is a graphical user interface (GUI)-based workbench designed to aid a developer in building software applications with an integrated environment combined with all the required tools at hand. Most common topographies, such as debugging, version control and data structure browsing, help a developer quickly execute actions without switching to other applications. Thus, it helps maximize productivity by providing similar user interfaces (UI) for related components and reduces the time taken to learn the language. An IDE supports single or multiple languages. The concept of IDE evolved from simple command-based software which was not as useful as menu-driven software. Modern IDEs are mostly used in the context of visual programming, where applications are quickly created by moving programming building blocks or code nodes that generate flowchart and structure diagrams, which are compiled or interpreted. Selecting a good IDE is based on factors, such as language support, operating system (OS) needs and costs associated with using the IDE etc. Examples for IDEs

  • NetBeans: NetBeans is an integrated development environment (IDE) for Java. NetBeans allows applications to be developed from a set of modular software components called modules. NetBeans runs on Windows, macOS, Linux and Solaris. In addition to Java development, it has extensions for other languages like PHP, C, C++, HTML5,[4] and

JavaScript. Applications based on NetBeans, including the NetBeans IDE, can be extended by third party developers.

  • Microsoft Visual Studio: Microsoft Visual Studio is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs, as well as websites, web apps, web services and mobile apps. Visual Studio uses Microsoft software development platforms such as Windows API, Windows Forms, Windows Presentation Foundation, Windows Store and Microsoft Silverlight. It can produce both native code and managed code.
  • Eclipse: Eclipse is an integrated development environment (IDE) used in computer programming.[6] It contains a base workspace and an extensible plug-in system for customizing the environment. Eclipse is written mostly in Java and its primary use is for developing Java applications, but it may also be used to develop applications in other programming languages via plug-ins, including Ada, ABAP, C, C++, C#, Clojure, COBOL, D, Erlang, Fortran, Groovy, Haskell, JavaScript, Julia,[7] Lasso, Lua, NATURAL, Perl, PHP, Prolog, Python, R, Ruby (including Ruby on Rails framework), Rust, Scala, and Scheme. It can also be used to develop documents with LaTeX (via a TeXlipse plug-in) and packages for the software Mathematica. Development environments include the Eclipse Java development tools (JDT) for Java and Scala, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others.

2.3 Do a comparison of the features of the IDEs you’ve mentioned

in 2.3. Analyze the common features that a developer has

access to in all these IDEs.

Types of IDE software IDE software solutions differ in the types of features and tools they offer. Typically, an IDE software provides a debugger, build automation tools, and source code editor, Modern IDEs include intelligent code completion. Some IDEs like Eclipse and NetBeans offer a compiler,

  • Eclipse uses a custom compiler which sometimes gives it an edge over the normal Java compiler.
  • NetBeans, on the other hand, is more user-friendly as one does not need to install plugins, unlike Eclipse many basic plugins come installed in NetBeans.
  • Learning to use NetBeans is also easier than Eclipse because of its simpler UI but on the other hand, Eclipse provides different windows and perspectives making it more flexible.
  • NetBeans is more stable than Eclipse as with subsequent updates NetBeans is less susceptible to annoying bugs and crashes and because of its huge plugin library, any installation of incompatible plugins can cause problems for your project.
  • Both of these IDEs can get slow, but Eclipse has a tendency to get slower than NetBeans.

Task 03

The details of the application you are required to build is as follows:

  • You are given a text file (.txt) file that consists of marks for 10 subjects in a course for students.
  • The contents of the text file would consist of lines of student marks (100 lines) that are in the following format: Name of the student: mk1, mk2, mk3, mk4, mk5, mk6, mk7, mk8, mk9, mk (example Sam:70,80,75,85,77,88,95,98,100,95) Note that the name of the student is followed by a colon (:) followed by a comma separated list of the student’s marks for the 10 subjects.
  • Each new line would consist of marks of a different student. (Assume that there are no students with the same name – student names are unique) You are required to create a simple GUI application that reads this text (.txt) file and loads all student names in to a dropdown box on a screen. When the user selects a student name from the dropdown box and clicks on a button, the student’s average and the grade should be displayed on the screen. The grading system is as follows:

Average < 40 – Fail Average >= 40 – Pass Average >= 65 – Merit Average >= 80 – Distinction The application is also required to display a summary consisting of the following information on another screen.

  • No. of students who Passed the course
  • No. of students who Failed the course
  • No. of students who got a Merit grade
  • No. of students who got a Distinction grade You are required to fulfil the following in terms of building the above application: 3.1. Use an Integrated Development Environment (IDE) of your choice to Implement the above-mentioned application. Include source code and screen shots of the application. (Task covers LO3, P3) 3.2 Provide evidence of how the IDE was used to manage the development of your code. (Task covers LO3, M3) 3.3 Do an evaluation of developing your application using an IDE versus developing it without using an IDE. You may discuss both advantages as well as disadvantages (if any). (Task covers LO3, D3) Intergraded Development environment – Apache NetBeans 11.