Developing an Event-Driven Java Application for Mobile Devices
VerifiedAdded on 2020/05/04
|27
|4937
|106
AI Summary
The task is to create a Java-based student management system that allows users to add, update, delete, and view student information. The project emphasizes applying object-oriented principles such as encapsulation, inheritance, and polymorphism. Students are required to follow Java coding standards for naming conventions, spacing, and commenting. The NetBeans IDE will be used extensively for writing, debugging, and running the application. Key features of the system include a user-friendly interface for data entry, robust error handling, and efficient data management using arrays or collections. This assignment aims to enhance students' understanding of Java programming, OOP principles, and software development best practices.

Running head: ALGORITHMS AND PROGRAMMING
Algorithms And Programming
Name of the Student:
Name of the University:
Author note:
Algorithms And Programming
Name of the Student:
Name of the University:
Author note:
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

1ALGORITHMS AND PROGRAMMING
TABLE OF CONTENTS
LO1...................................................................................................................................................... 2
Algorithms.........................................................................................................................2
Writing simple algorithms....................................................................................................3
Example: Binary Search........................................................................................................4
Process of Developing Applications......................................................................................6
LO2...................................................................................................................................................... 8
Programming Paradigms....................................................................................................8
Procedural Programming..................................................................................................... 8
Object Oriented Programming...........................................................................................10
Event Driven Programming................................................................................................ 14
LO3.................................................................................................................................................... 16
A Mobile Application........................................................................................................16
Aim..................................................................................................................................... 16
Method...............................................................................................................................17
Source Code....................................................................................................................... 17
Debugging.......................................................................................................................... 21
Coding Standards............................................................................................................... 22
TABLE OF CONTENTS
LO1...................................................................................................................................................... 2
Algorithms.........................................................................................................................2
Writing simple algorithms....................................................................................................3
Example: Binary Search........................................................................................................4
Process of Developing Applications......................................................................................6
LO2...................................................................................................................................................... 8
Programming Paradigms....................................................................................................8
Procedural Programming..................................................................................................... 8
Object Oriented Programming...........................................................................................10
Event Driven Programming................................................................................................ 14
LO3.................................................................................................................................................... 16
A Mobile Application........................................................................................................16
Aim..................................................................................................................................... 16
Method...............................................................................................................................17
Source Code....................................................................................................................... 17
Debugging.......................................................................................................................... 21
Coding Standards............................................................................................................... 22

2ALGORITHMS AND PROGRAMMING
LO1
Algorithms
An algorithm is a computer or mathematical term used in the process of solving
problems. This describes each step that the computer must take or follow to solve particular
class of problems or achieve its goal. Algorithms can perform automated reasoning, data
processing tasks and calculations. It is considered as an effective method, which can be
presented within a finite space and time. Algorithms are generally written in well-defined
formal languages for the calculation of functions. The process starts following algorithms
from the initial state. Inputs are taken, the instructions further describe the procedure of
computation and finally the outputs are delivered. Finite number of successful states are
covered before the terminating the process after reaching the final state.Algorithms are not
necessarily deterministic in their change of state. Randomized algorithms incorporate state
changes through random or variable inputs.
Some basic advantages of writing algorithms are:
Algorithms are stepwise representation of solutions to given problems, thus it is easier
to understand.
These are written in pseudo code therefore, people without the knowledge of
programming language can analyze them.
It is easy to debug algorithms as they have their own logical sequence.
LO1
Algorithms
An algorithm is a computer or mathematical term used in the process of solving
problems. This describes each step that the computer must take or follow to solve particular
class of problems or achieve its goal. Algorithms can perform automated reasoning, data
processing tasks and calculations. It is considered as an effective method, which can be
presented within a finite space and time. Algorithms are generally written in well-defined
formal languages for the calculation of functions. The process starts following algorithms
from the initial state. Inputs are taken, the instructions further describe the procedure of
computation and finally the outputs are delivered. Finite number of successful states are
covered before the terminating the process after reaching the final state.Algorithms are not
necessarily deterministic in their change of state. Randomized algorithms incorporate state
changes through random or variable inputs.
Some basic advantages of writing algorithms are:
Algorithms are stepwise representation of solutions to given problems, thus it is easier
to understand.
These are written in pseudo code therefore, people without the knowledge of
programming language can analyze them.
It is easy to debug algorithms as they have their own logical sequence.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

3ALGORITHMS AND PROGRAMMING
Writing programs becomes easier once the algorithm is ready. The programmer can
study each module of the algorithm separately and code them accordingly.
However, special care must be taken that algorithms are aimed at decreasing the
complexity of problems. Algorithms should be such that, both time and memory usage are
reduced.
Writing simple algorithms
As an example, a simple problem of adding five numbers taken as user input, is
presented using algorithms.
Step 1: START
Step 2: Declare the necessary variables for user input, calculation, loop counter and so
on.
Step 3: Set variable SUM to 0.
Step 4: Set loop counter to 1.
Step 5: If loop counter value is less than or equal to 5, goto Step 5 else goto step 10.
Step 6: Take user input.
Step 7: Add the user input variable to the SUM variable.
Step 8: Store the addition result in the SUM variable itself.
Step 9: Go to step 5.
Step 10: Print SUM.
Step 11: END
Writing programs becomes easier once the algorithm is ready. The programmer can
study each module of the algorithm separately and code them accordingly.
However, special care must be taken that algorithms are aimed at decreasing the
complexity of problems. Algorithms should be such that, both time and memory usage are
reduced.
Writing simple algorithms
As an example, a simple problem of adding five numbers taken as user input, is
presented using algorithms.
Step 1: START
Step 2: Declare the necessary variables for user input, calculation, loop counter and so
on.
Step 3: Set variable SUM to 0.
Step 4: Set loop counter to 1.
Step 5: If loop counter value is less than or equal to 5, goto Step 5 else goto step 10.
Step 6: Take user input.
Step 7: Add the user input variable to the SUM variable.
Step 8: Store the addition result in the SUM variable itself.
Step 9: Go to step 5.
Step 10: Print SUM.
Step 11: END
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

4ALGORITHMS AND PROGRAMMING
Below, an example of the most commonly used searching algorithm is presented to
discuss the advantage of using algorithms, over brute forcing.
Example: Binary Search
Binary search is the most preferred searching technique. It divides the array into
smaller sections after each iteration, while it approaches to search for the desired element
(Morgado, Heras and Marque-Silva, 2012). The algorithm for this problem is presented and
discussed below:
Given is an array with n number of elements, starting from n0and ending at nn-1. For
this algorithm to work, it is a pre-requirement that the array must be sorted. The algorithm
part for the searching is shown below.
Step 1: Set variable min to 0 and max to n − 1.
Step 2: If min > max, the search terminates as unsuccessful, else go to step 3.
Step 3: Set mid as the position of middle element to (min + max)/ 2.
Step 4: If Arraymid < Item, set min to mid + 1 and go to step 2.
Step 5: If Arraymid >Item, set max to mid − 1 and go to step 2.
Step 6: Now else if Arraymid = Item, the search is done; return mid+1value and go to
step 7, otherwise go to step 2.
Below, an example of the most commonly used searching algorithm is presented to
discuss the advantage of using algorithms, over brute forcing.
Example: Binary Search
Binary search is the most preferred searching technique. It divides the array into
smaller sections after each iteration, while it approaches to search for the desired element
(Morgado, Heras and Marque-Silva, 2012). The algorithm for this problem is presented and
discussed below:
Given is an array with n number of elements, starting from n0and ending at nn-1. For
this algorithm to work, it is a pre-requirement that the array must be sorted. The algorithm
part for the searching is shown below.
Step 1: Set variable min to 0 and max to n − 1.
Step 2: If min > max, the search terminates as unsuccessful, else go to step 3.
Step 3: Set mid as the position of middle element to (min + max)/ 2.
Step 4: If Arraymid < Item, set min to mid + 1 and go to step 2.
Step 5: If Arraymid >Item, set max to mid − 1 and go to step 2.
Step 6: Now else if Arraymid = Item, the search is done; return mid+1value and go to
step 7, otherwise go to step 2.

5ALGORITHMS AND PROGRAMMING
Step 7: Else,
The linear search technique is considered as a brute forcing concept. In the linear
search technique, the item being searched for is checked with every element in the array from
the very beginning. In the best-case scenario, this is an excellent technique where the element
can be found in the very first index. However, for the worst case, the element would be found
in the very last array index. This is not a time efficient approach. Considering the time
complexity, the linear search approach has a O(n) complexity. Whereas, the binary search has
a O(log n) complexity, which is lesser than that of the brute forcing technique of linear search
(Lipwoski and Lipwoska, 2012).
In this case, where it is necessary to build a mobile-based application or software,
using proper algorithms certainly helps in saving mobile resources. Algorithms that make a
function to work with better efficiency must be preferred over brute force techniques. A well-
planned algorithm not only reduces time complexity but they also tend to minimize memory
complexity whereas, brute forcing may deplete resources and take longer time. This saves
mobile battery and helps user to get their job done with haste and efficiency.
Below, the JAVA code variant of the Binary Search algorithm is presented.
Comments are provided wherever necessary to express the code’s relation with the algorithm.
importjava.util.Scanner;
classBinarySearch
{
public static void main(String args[])
{
inti, min, max, mid, n, search, array[];
Scanner in = new Scanner(System.in);
Step 7: Else,
The linear search technique is considered as a brute forcing concept. In the linear
search technique, the item being searched for is checked with every element in the array from
the very beginning. In the best-case scenario, this is an excellent technique where the element
can be found in the very first index. However, for the worst case, the element would be found
in the very last array index. This is not a time efficient approach. Considering the time
complexity, the linear search approach has a O(n) complexity. Whereas, the binary search has
a O(log n) complexity, which is lesser than that of the brute forcing technique of linear search
(Lipwoski and Lipwoska, 2012).
In this case, where it is necessary to build a mobile-based application or software,
using proper algorithms certainly helps in saving mobile resources. Algorithms that make a
function to work with better efficiency must be preferred over brute force techniques. A well-
planned algorithm not only reduces time complexity but they also tend to minimize memory
complexity whereas, brute forcing may deplete resources and take longer time. This saves
mobile battery and helps user to get their job done with haste and efficiency.
Below, the JAVA code variant of the Binary Search algorithm is presented.
Comments are provided wherever necessary to express the code’s relation with the algorithm.
importjava.util.Scanner;
classBinarySearch
{
public static void main(String args[])
{
inti, min, max, mid, n, search, array[];
Scanner in = new Scanner(System.in);
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

6ALGORITHMS AND PROGRAMMING
System.out.println("Enter number of elements");
n = in.nextInt();
array = new int[n];
System.out.println("Enter " + n + " integers");
for (i = 0; i< n; i++)
array[i] = in.nextInt();
System.out.println("Enter value to find");
item = in.nextInt();
min = 0;
max = n - 1;// Set variable min to 0 and max to n − 1.
while( min <= max )// If min > max, the search terminates as unsuccessful, else continue.
{
mid = (min + max)/2; // Set mid as the position of middle element to (min + max)/ 2.
if ( array[mid] < item )// If Arraymid<Item, set min to mid + , go to loop
checking.
min = mid + 1;
else if ( array[mid] > item ) // If Arraymid>Item, set max to mid – 1, go to loop
checking.
max = mid - 1;
else // if Arraymid = Item, the search is done; return mid+1 value and exit.
{
System.out.println(item + " found at location " + (mid + 1) + ".");
break;
}
}
if ( min > max )
System.out.println(item + " is not present in the list.");
}
}
Process of Developing Applications
The steps that must be followed to write a program are:
Understanding the problem.
System.out.println("Enter number of elements");
n = in.nextInt();
array = new int[n];
System.out.println("Enter " + n + " integers");
for (i = 0; i< n; i++)
array[i] = in.nextInt();
System.out.println("Enter value to find");
item = in.nextInt();
min = 0;
max = n - 1;// Set variable min to 0 and max to n − 1.
while( min <= max )// If min > max, the search terminates as unsuccessful, else continue.
{
mid = (min + max)/2; // Set mid as the position of middle element to (min + max)/ 2.
if ( array[mid] < item )// If Arraymid<Item, set min to mid + , go to loop
checking.
min = mid + 1;
else if ( array[mid] > item ) // If Arraymid>Item, set max to mid – 1, go to loop
checking.
max = mid - 1;
else // if Arraymid = Item, the search is done; return mid+1 value and exit.
{
System.out.println(item + " found at location " + (mid + 1) + ".");
break;
}
}
if ( min > max )
System.out.println(item + " is not present in the list.");
}
}
Process of Developing Applications
The steps that must be followed to write a program are:
Understanding the problem.
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

7ALGORITHMS AND PROGRAMMING
Designing a solution.
Drawingthe respective flow chart
Writing thealgorithm or pseudo-code
Choosing the right language for the problem.
Writing the code.
Testing and debugging.
Releasing the application.
Therefore, it can be concluded that, algorithms are not the actual code that the
computer feeds upon. The algorithm provides the logic. The programmers then need to
understand them clearly and finally convert them into specific code using suitable
programming languages. Well-optimized algorithms must be written with the aim to boost
technical performance of the systems.
The code is then needed to be converted into the machine language for processing.
This is done through certain methods. The role of preprocessor, compiler and linker and
interpreter is discussed below.
Designing a solution.
Drawingthe respective flow chart
Writing thealgorithm or pseudo-code
Choosing the right language for the problem.
Writing the code.
Testing and debugging.
Releasing the application.
Therefore, it can be concluded that, algorithms are not the actual code that the
computer feeds upon. The algorithm provides the logic. The programmers then need to
understand them clearly and finally convert them into specific code using suitable
programming languages. Well-optimized algorithms must be written with the aim to boost
technical performance of the systems.
The code is then needed to be converted into the machine language for processing.
This is done through certain methods. The role of preprocessor, compiler and linker and
interpreter is discussed below.

8ALGORITHMS AND PROGRAMMING
In computer programming, a preprocessor is the program, which processes input data
for producing output, which is then used as input to other programs or modules. The output is
thus said to be the preprocessed version of the input data.Subsequent programs like the
compilers often use this.
Compiler is a special type of program, which processes statements that are written in
some programming language and converts them into respective machine code that is then
used by the computer’s processor to execute them. The whole program is taken into
consideration at once unlike the interpreter.
Linker helps to combinelibrary files with object files of an application to create a
single executable file. The object files used to generate executable filesare therefore produced
at different times or even by different languages.
In the field of computer science and programming, interpreter is that computer
program, which directly executes instructions that are written in somescripting
or programming language, without the requirement of compiling them into the machine
language. Unlike the compiler, the interpreter translates one code statement at a time.
LO2
Programming Paradigms
In computer programming, a preprocessor is the program, which processes input data
for producing output, which is then used as input to other programs or modules. The output is
thus said to be the preprocessed version of the input data.Subsequent programs like the
compilers often use this.
Compiler is a special type of program, which processes statements that are written in
some programming language and converts them into respective machine code that is then
used by the computer’s processor to execute them. The whole program is taken into
consideration at once unlike the interpreter.
Linker helps to combinelibrary files with object files of an application to create a
single executable file. The object files used to generate executable filesare therefore produced
at different times or even by different languages.
In the field of computer science and programming, interpreter is that computer
program, which directly executes instructions that are written in somescripting
or programming language, without the requirement of compiling them into the machine
language. Unlike the compiler, the interpreter translates one code statement at a time.
LO2
Programming Paradigms
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

9ALGORITHMS AND PROGRAMMING
Programming paradigm is defined as the way of doing programs. However, a
paradigm cannot be grouped under as a programming language. Particular programming
languages follow their respective paradigm’s style. Supposedly, programming language A
follows the paradigm style B, therefore, it can be stated that Programming language-A is a B-
type programming language. These languages best express those particular paradigms.
The most commonly followed programming paradigms are:
Procedural Programming
Procedural programming is derived from the structure oriented programming
paradigm. This relies upon the concept of procedure calls. Procedures are also called
routines, sub-routines or functions, which contain series of computational instructions
to be performed. These procedures may get called anytime while in a program’s
execution. The computer processor provides hardware support to the procedural
programs through stack registers and instructions, to call procedures and return from
them. FORTRAN, COBOL and C are some examples of the mostly valued Procedural
Programming Languages.
These are high level programming languages. In multi-function programs, lots
of important data items are stored globallyfor the ease of access by all
functions.Global data are unsafe due to changesthat are accidentally made by
function. In case of large programs, it becomes difficult to identify which data or
variablebeing controlled by which function.
Preferable IDE
Programming paradigm is defined as the way of doing programs. However, a
paradigm cannot be grouped under as a programming language. Particular programming
languages follow their respective paradigm’s style. Supposedly, programming language A
follows the paradigm style B, therefore, it can be stated that Programming language-A is a B-
type programming language. These languages best express those particular paradigms.
The most commonly followed programming paradigms are:
Procedural Programming
Procedural programming is derived from the structure oriented programming
paradigm. This relies upon the concept of procedure calls. Procedures are also called
routines, sub-routines or functions, which contain series of computational instructions
to be performed. These procedures may get called anytime while in a program’s
execution. The computer processor provides hardware support to the procedural
programs through stack registers and instructions, to call procedures and return from
them. FORTRAN, COBOL and C are some examples of the mostly valued Procedural
Programming Languages.
These are high level programming languages. In multi-function programs, lots
of important data items are stored globallyfor the ease of access by all
functions.Global data are unsafe due to changesthat are accidentally made by
function. In case of large programs, it becomes difficult to identify which data or
variablebeing controlled by which function.
Preferable IDE
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

10ALGORITHMS AND PROGRAMMING
Choosing the right Integrated Development Environment (IDE) is necessary to
write programs. Visual Studio is considered to be one of the most preferable IDE used
for C-language programming. It offers the best services and tools for procedural
programming via C. It offers keyboard shortcuts for easy accessing of commonly used
C commands. It also has the debugger mode to help the programmer rectify bugs or
errors.
Source Code
Here is an example of procedural programming through a C program snippet.
#include <stdio.h>
void display()
{
printf("\nAfter swapping… \n The First Number = %d\n", first);
printf("The Second Number = %d", second);
} //control is sent back to main
int main()
{
intfirst, second, temp;
printf("Enter the first number: ");
scanf("%d", &first);
printf("Enter the second number: ");
scanf("%d",&second);
temp = first;
Choosing the right Integrated Development Environment (IDE) is necessary to
write programs. Visual Studio is considered to be one of the most preferable IDE used
for C-language programming. It offers the best services and tools for procedural
programming via C. It offers keyboard shortcuts for easy accessing of commonly used
C commands. It also has the debugger mode to help the programmer rectify bugs or
errors.
Source Code
Here is an example of procedural programming through a C program snippet.
#include <stdio.h>
void display()
{
printf("\nAfter swapping… \n The First Number = %d\n", first);
printf("The Second Number = %d", second);
} //control is sent back to main
int main()
{
intfirst, second, temp;
printf("Enter the first number: ");
scanf("%d", &first);
printf("Enter the second number: ");
scanf("%d",&second);
temp = first;

11ALGORITHMS AND PROGRAMMING
first = second;
second = temp;
display(); //calls function display
return 0;
}
This program is written to perform swapping of two numbers using a third
variable. The program is written in C. The program always starts inside the Function
main() and follows instructions in the linear order. At the end of the main() function,
the display() function is called, its instructions are executed and the control is sent
back to the main() where the program finally terminates by returning 0.
Object Oriented Programming
Object Oriented Programming, commonly known, as OOP is a programming
paradigm that emphasizes upon the use of classes, objects and data rather than
following actions and logics only. Classes are required to framed with the attributes
and methods that its objects must behold. The objects then defined under that class
will comprise of the same. Several objects can be made of one class, thus having the
same attributes and behaviors or functions. Functions here, can be accessed using the
objects and then their respective values can be modified. Each object can hence be
treated as a separate entity. Object Oriented Programming provides several features
that help in building secured applications. Inheritance, Data Abstraction,
Encapsulation, Polymorphism and Data Hiding are some of the best OOP features
(Liang, 2013).
first = second;
second = temp;
display(); //calls function display
return 0;
}
This program is written to perform swapping of two numbers using a third
variable. The program is written in C. The program always starts inside the Function
main() and follows instructions in the linear order. At the end of the main() function,
the display() function is called, its instructions are executed and the control is sent
back to the main() where the program finally terminates by returning 0.
Object Oriented Programming
Object Oriented Programming, commonly known, as OOP is a programming
paradigm that emphasizes upon the use of classes, objects and data rather than
following actions and logics only. Classes are required to framed with the attributes
and methods that its objects must behold. The objects then defined under that class
will comprise of the same. Several objects can be made of one class, thus having the
same attributes and behaviors or functions. Functions here, can be accessed using the
objects and then their respective values can be modified. Each object can hence be
treated as a separate entity. Object Oriented Programming provides several features
that help in building secured applications. Inheritance, Data Abstraction,
Encapsulation, Polymorphism and Data Hiding are some of the best OOP features
(Liang, 2013).
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 27
Related Documents

Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.