Professional Documents
Culture Documents
3rd Programming Assignment
3rd Programming Assignment
Table of Contents
Learning outcome 1: Define basic algorithms to carry out an operation and outline the process of
programming an application....................................................................................................................2
P1: Algorithm, Explanation, Problem and Example:............................................................................2
M1: Application Programming process.................................................................................................2
D1: Implementation of an algorithm.....................................................................................................2
Learning outcome 2: Characteristics of procedural, object-orientated and event-driven
programming.............................................................................................................................................3
P2: Explanation, Features, and Relationships:.....................................................................................3
M2: Compare, Contrast used with a source code of an application:.....................................................4
D2: Critically Evaluation, code structure and characteristics...............................................................9
Learning outcome 3: Using an IDE, write fundamental algorithms in code.......................................11
P3: Write a program that implements an algorithm using an IDE:....................................................11
M3: Use of an IDE for development of applications:..............................................................................15
D3: Use the IDE to control the program's development process:............................................................16
Learning outcome 4: Importance of a coding standard and debugging process................................16
P4: Debugging procedure and IDE debugging facilities:....................................................................16
M4: Evaluate, help develop more secure debugging, robust applications:.........................................17
D4: Evaluate why a coding standard is necessary:..............................................................................18
P5: Outline the coding standard you have used in your code:............................................................18
1
Learning outcome 1: Define basic algorithms to carry out an operation and
outline the process of programming an application.
P1: Algorithm, Explanation, Problem and Example:
A collection of instructions called an algorithm is what a computer must follow in order to
conduct computations or other problem-solving tasks. A formal definition of an algorithm is that
it is a finite set of instructions that are carried out in a certain order to complete a specified task.
Characteristics:
Language independent
Input
Output
Finiteness
Validity
2
Divide the algorithm into sections.
Begin with a basic example.
Validate with a reliable implementation.
Document your procedure.
// function declaration
int main ()
int a = 10;
int b = 20;
int res;
3
// call to sum function
std::cout << a << "+" << b << "=" << res << std::endl;
return 0;
int result;
return result;
OOP
// C++ program to implement the ATM
// Management System
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
class Bank {
4
// Public variables
public:
// Function to set the person's data
void setvalue()
{
cout << "Enter name\n";
cin.ignore();
5
void deposit()
{
cout << "\nEnter amount to be Deposited\n";
cin >> amount;
}
// Function to show the balance amount
void showbal()
{
tot = tot + amount;
cout << "\nTotal balance is: " << tot;
}
// Function to withdraw the amount in ATM
void withdrawl()
{
int a, avai_balance;
cout << "Enter amount to withdraw\n";
cin >> a;
avai_balance = tot - a;
cout << "Available Balance is" << avai_balance;
}
};
// Driver Code
int main()
{
// Object of class
Bank b;
6
int choice;
7
break;
case 3:
b.deposit();
break;
case 4:
b.showbal();
break;
case 5:
b.withdrawl();
break;
case 6:
exit(1);
break;
default:
cout << "\nInvalid choice\n";
}
}
}
8
call event-handler for event_nn with event parameters else handle unrecognized event // ignore or raise
exception
end loop
Object-oriented programming revolves around the concepts of objects and classes. In Java, the
classes are referred as templates for the objects while the objects are instances of a class so, the
objects can inherit all the characteristics, variables, and functions of the class.
Procedural programming gets its name due to the concept of procedural calls. Like other
programming paradigms, it has its own advantages and disadvantages. So, take note of them and
compare them with your requirements to know whether the popular programming paradigm
works out for you or not.
fact = fact * i;
cout « "Factorial of " << num « " is: " << fact << endl;
return 0;
9
Object oriented programming
The software is written as a set of communication-oriented classes and objects. Objects are the
smallest and most fundamental entities, and all computations are conducted on them alone.
import java.io.•;
class GFG {
System.out.println("GfG!");
class Signup { int userid; String name; String emailid; char sex; long mob;
public void create(int userid, String name, String emailid, char sex, long mob){
this.emailid = "radha.89@gmail.com";
this.sex = 'F';
this.mob = 900558981;
Event-driven paradigms
o Service oriented
o Time driven
import asyncio
1p = asyncio.get_event_loop()
1p.call_soon(hello_world, 1p)
1p.run_forever() 1p.close()
#include<vector>
10
#include<stdio.h>
#include<cstring>
#include<fstream>
#include<algorithm>
class course {
char name[80],branch[50];
void input() {
cin>>reg; fflush(stdin);
11
cout<<"\t\tDisplay Records";
cout«"\n";
system("PAUSE");
system("CLS");
}; vector <course>v;
void get_file()
course x;
2 -s 2 n .
fstream f;
f.open("College.txt",ios::out);
for(int i=0;i<v.size();i++) {
(.close();
for(i=0;i<v.size();
} return ta;
12
1++) if(strcmp(v[i].name,name)==0)
Figure 1
Figure 2
13
Figure 3
Figure 4
Figure 5
14
Figure 6
Figure 7
15
D3: Use the IDE to control the program's development process:
An IDE is used by developers to create, manage, and execute code while their applications are
running. It simplifies the development process by abstracting various parts of editing code into
separate apps.
Here are the best available IDEs for Java developers:
Eclipse.
NetBeans.
IntelliJ IDEA.
Visual Studio.
Common features of an IDE
IDEs have been around for decades.
IDEs have evolved and changed throughout time, from being only a platform for debugging and
testing to an integrated piece of software that may act as an extension of the developer.
Text editor:
Debugger:
Compiler:
Code completion:
elax (n.d.). [online] Available at: https://www.sitepoint.com[Accessed 22 Feb. 2022].
Debugging facilities
Common debugging features include the ability to run or halt the target program at specific
points, display the contents of memory, CPU registers, or storage devices (such as disc drives),
and modify memory or register contents to enter selected test data that could be the cause of
faulty program execution. If a segment of code gives unexpected results, try running that area of
code in isolation. elax (n.d.). [online] Available at:
http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=
%2Fcom.qnx.doc.ide.userguide%2Ftopic%2Fdebug_Base_.html [Accessed 21 Jul.
2022].
16
Figure 8
Figure 9
17
elax (n.d.). [online] Available at: https://www.quora.com/How-can-the-debugging-
process-be-used-to-help-develop-more-secure-robust-applications [Accessed 21 Jul.
2022].
D4: Evaluate why a coding standard is necessary:
For software engineers, coding standards are crucial for various reasons: Maintenance accounts
for 40% to 80% of the entire cost of software.
Benefits of OOP
Data Redundancy
Polymorphism Flexibility
Re-usability
Code Maintenance
Security
Easy troubleshooting
18