You are on page 1of 11

Algorithm

A method or process used to solve a problem is called an algorithm in programming. It is based on


carrying out a series of prescribed activities that, when combined, define how to do anything, and
our computer will always carry out those specific operations in that order. Programming is only one
aspect of algorithm creation. It necessitates knowledge of the potential solutions to a
computational issue, as well as the hardware, networking, programming language, and
performance limitations associated with each one.

In computer programming, there are many ways to solve the problems or errors. Algorithms help
us to find the best possible way to solve the problems. By doing that we can improve the efficiency
of the program. The speed of the program executing the problem can be improved by using the
algorithms.

The following are famous algorithms of programming algorithms exist:

1. Sort algorithms
2. Search algorithms
3. Hashing algorithms
4. Primality testing algorithms

Sort algorithms

One of the fundamental operations we carry out on things is sorting. Children are taught to sort
even as young children in order to help them grow as thinkers. Software and computers are not an
exception. One of the areas of algorithms that a developer has to be familiar with is sorting
components. A sorting algorithm will arrange the elements in a list in a certain order, such as
numerical or alphabetical order. It might take a long time to sort a list of objects, especially if the
list is lengthy. To achieve this, a computer program may be developed, greatly simplifying the
process of sorting a list of data. Java has a broad selection of sorting algorithms such as bubble
sort, selection sort, shuttle sort, shell sort, merge sort, counting sort and radix sort and quick sort.

Search algorithms

An element may be checked or retrieved from any data structure where it is stored using search
algorithms. The effective usage of the search algorithm makes the difference between a quick
application and a slower one while looking for data. A basic, fundamental computer process that
locates a specific piece of data amid a group of data is the use of search algorithms. There are
several types of search algorithms such as linear search, binary search, jump search, interpolation
search, exponential search and Fibonacci search etc.

Hashing algorithms

When given an input, hashing algorithms produce a fixed-length output (the hash, or hash value).
The original data is condensed into the hash value. Cryptographic hash functions are created via
hashing algorithms. It is a mathematical formula that converts data of any size into a fixed-size
hash. The goal of a hash function algorithm is to be a one-way function that is impossible to invert.

Primality testing algorithms

An algorithm called the primality test may be used to determine if a positive integer is a prime
number or not. There are several ways to determine if a number is prime or not. It is also possible
to examine a number's primality by seeing if it is a composite number or not; if it is neither a
composite number nor 1, then it must be a prime number.

Algorithms used in Student Registration

Algorithms in programming is to solve the problem using method or process. In this case, Student
Registration program solve many things in real life. The reason why we program the Student
Registration is for the students who cannot register the registration of the school in person.
Nowadays, it is not easy to go out and do the things we like. If the students want to attend the
class, school or university, they have to come to the school or university to register for attending
the school. For the students, who live far away from the school or university, they are unable to
register the form of the university. To solve all of those problems, we present the Student
Registration program which is the online registration program. This program will help the students
who live far away to fill the registration in person. And for those students who are unable to come
to university because of many reasons. Student Registration will help them to register the
university registration to attend. Student Registration program is way more convenient to use
because students can register from anywhere internet is available. In this program, except main
method, there are two functions we used, choose() function and payment() function. The choose()
function describe which major is chosen by the student, how many years will it takes, how much it
costs and which bachelor degree will get. The payment() function also describe how will the
student want to make the payment, installment or pay at once. If the student chooses the
installment, how many months he wants to separate the payment, he has to choose between
2months, 3months and 4 months. If the student has chosen the months he wants to pay, the
amount of money it will costs per month will be shown. The main algorithm we used in Student
Registration is sorting algorithm because we input all the information of the students in order. And
then we retrieve the all the information of the students who registered in the Student Registration
program. Sorting algorithms help us to store the information of the students in order.

Programming paradigms

A programming paradigm is a category, a fashion, or a method of programming. Programming


paradigms are many organizational structures that can be used with a particular program or
programming language. Each paradigm has a unique set of structures, attributes, and ideas about
how to approach typical programming issues. All disciplines, including psychology, sociology,
etymology, computer science, and others, employ paradigms. New programming languages
develop from existing languages in the field of computer science and add, remove, and combine
features in novel ways. It makes sense to employ several paradigms for various projects since
different paradigms are better suited for various sorts of challenges.

Procedural programming

A programming paradigm known as procedural programming is based on the notion that programs
are collections of instructions that must be carried out. It is a style of programming where
statements are organized into procedures using the idea of procedure calls (also known as
subroutines or functions). A procedure can access and change global data variables as well as local
data that is not available from outside the process's scope. They are a collection of instructions that
detail step-by-step what the computer should accomplish. Top-down languages are referred
regarded as procedural programming languages. Early programming languages were primarily
procedural. Some characteristics of procedural programming are

1. The methodology used in procedural programming is top-down.


2. The program is broken up into sections of code called functions, and each function carries
out a certain purpose.
3. Real-world processes are modeled by procedural programming as "procedures" that operate
on "data."
4. Data and functions are independent of one another.
5. In a software, data may move around at will.
6. It is simple to comprehend a program's logic.
7. A function can call another function to obtain its data.
Above picture is the example code of the procedural programming in java.

Object Oriented Programming

Object-oriented programming is one of the most well-liked paradigms for programming (OOP).
Separating concerns into entities that are written as objects is the fundamental idea behind OOP.
All real-world entities are represented by Classes in this framework. Since objects are instances of
classes, they each include a state and a behavior. The user or viewer sees objects as they carry out
the responsibilities you've given them. Implementing real-world concepts like inheritance, hiding,
polymorphism, etc. in programming is the goal of object-oriented programming. The primary goal
of OOP is to link everything together data and the functions that use them such that only that
function and no other section of the code may access the data. The characteristics of the object-
oriented programming will be explained in below.

Abstraction

One of the fundamental ideas of object-oriented programming (OOP) languages is abstraction. Its
fundamental objective is to manage complexity by concealing extraneous information from the
user. That enables the user to add more intricate reasoning on top of the abstraction offered
without being aware of all the complexity that is concealed. That idea is quite general and is not
exclusive to object-oriented programming.

Encapsulation

One of the essential components of object-oriented programming is encapsulation. Fields and


methods are bundled into a single class, which is referred to as encapsulation. It restricts access to
and modification of a class's fields and methods by exterior classes. Additionally, this facilitates
data concealment.

Inheritance

Inheritance in Java is a concept that acquires the properties from one class to other classes; for
example, the relationship between father and son. Inheritance in Java is a process of acquiring all
the behaviors of a parent object. The concept of inheritance in Java is that new classes can be
constructed on top of older ones.

Polymorphisms

Polymorphism is a fundamental idea in object-oriented programming (OOP), which allows


programmers to build code that may function differently depending on the environment and makes
their code more adaptable and extendable. The simplicity of object-oriented programming is what
gives it its power. One of the foundational ideas of object-oriented programming is polymorphism.
In actuality, it is a crucial component of OOP's strength.

Above picture is the example code of the object-oriented programming language.

Even-driven programming

Event-driven programming is a fantastic strategy for creating intricate systems. It uses the divide-
and-conquer strategy while also letting you use other strategies, such synchronous calls. In an
event-driven programming paradigm, entities (such as objects, services, and so on) communicate
with one another by passing messages through a middleman. Typically, the consumers handle the
messages once they have been placed in a queue. The following will provide an explanation of
even-driven programming's characteristics.

Events

A reaction able activity is referred to as an event. Events may be anything from mouse clicks to
keystrokes to sensor data input to messages provided by other applications.

Event Handler

When a certain event is triggered, an event handler is a sort of function or method that performs a
specified action. An event handler may, for instance, be a button that, upon user click, displays a
message and, upon subsequent user click, hides the message.

Trigger functions

In event-driven programming, trigger functions are functions that determine what code should be
executed when a certain event happens and which event handler should be utilized for the event.
The connecting element between events and event handlers is the trigger function.

Service Oriented

The ability to design programs specifically for services using event-driven programming is known
as service-oriented programming (SOP). SOP only uses a small portion of the computer's
processing capacity, and most services operate in the OS's background. Services that are running
in the background of a system and are activated by events are referred to as service-oriented
processing. The USB device recognition service on a contemporary PC is the most straightforward
illustration to comprehend. A notification is sent to the software service when a USB device is
inserted or uninstalled.

Time Driven

Time-driven is a concept in event-driven programming that describes a piece of code that executes
in response to a time trigger. This code can run once an hour, once a day, once per week, or once
per month, making it a pre-set job. Automatic Updates are one example of a time-driven
application in which the user may specify whether to upgrade or scan for and download updates.
Difference between procedural programming and object-
oriented programming

The programs are created using both procedural and object-oriented programming. High-level
programming languages define both of them.

Object-oriented Classes and objects are used in programming to build representations of the
environment seen in the actual world. In an application that uses object-oriented programming, a
group of objects that are called upon to seek a certain service or piece of information may pass
messages. Objects have the ability to transmit, receive messages, and process data-based
information.

Programming is done more from the top down using procedural programming, often known as
inline programming. While procedural programming tackles applications by tackling issues at the
bottom of the code, object-oriented programming employs classes and objects.

Classes in object-oriented programming might serve as a representation for the images in learn-to-
read books. A home might stand for a class and include anything the developer wants to define it,
such as its color, size, number of bathrooms, etc.

The learn-to-read book would be written on the page without any graphics in procedural
programming, which would enable the young reader to navigate the book. If the book's opening
narrative were altered, it may interrupt the flow of the rest of the narrative or render it illogical.
Even though learning to read the book would make programming using procedural programming
straightforward, it would be challenging for other readers of the book or programmers to contribute
to the plot in the case of procedural programming.

Procedural programming employs records, whereas object-oriented programming uses objects.

Classes are used in Object-oriented programming instead of modules and messages are used in
Object-oriented programming instead of procedure calls in procedural programming.

Procedural programming utilizes processes, whereas object-oriented programming uses data fields.

Explanation of Student Registration program

We used java programming language to develop the student registration program. Java is the
popular language to create the mobile application, desktop application and web application. Java
provided built-in-methods and built-in-functions which make easier for developer to develop the
program. In this program, we used some built-in-functions.
Import java util package

We import java util package into the program. Java util package contains classes for the collections
framework, legacy collection classes, event model, date and time facilities, internationalization, and
other utility classes (a string tokenizer, a random-number generator, and a bit array). In this
program, we used mainly for input of the user and array list of the student information.

Create class file and declaring global variables

We create the main method class file with the name of StudentRegister which has the public access
modifier. We declare with major with the datatype of the long to accept the major of the user and
majorChoice with the datatype of String to accept the major choice of the user. Both are declared
in static variable. Static variables are also known as class variables in Java. In other words, they
are members of a class and not an individual instance. Static variables will thus be initialized by
class initialization. And then we declare to array list of studentName to accept the registered
students’ name, studentPhoneNumberArray to accept the phone numbers and studentMajor to
accept the chosen majors of the students. They are also declared in static variable with access
modifier of public. And then we will explain the main method where the program starts working.
Main method of the program

In main method, we start decorating the output of the program with title of ‘Student Registration’.
We declared variable name of answer, datatype of character with the value of ‘y’ to start the while
loop. After that we start requesting the user to enter the name by outputting the ‘Enter a student
name: ’. To accept the input of the user, we call the scanner class from the util package and
declare the str which is string variable to accept the input from the user. We also request the age
of the user by outputting the ‘Enter age:’ and we also declare age variable which datatype is
integer to accept the input age form the user. In the same way, we also request student phone
number, parent name and parent
Coding standard

You might also like