You are on page 1of 26

Programming Methodology

Introduction to Programming

Structured Oriented Programming

The structured programming method is used to improve the clarity and quality of a software
program by using flow controls such as selection and repetition.

There are three main elements in structured programming.

Top Down Analysis

Top-down analysis is a way of approaching a problem. As it means the big picture of the
problem is identified first. Through an eagle-eye approach. After the problem is divided. Those
problems are divided again into smaller parts which are known as subdivisions. These
subdivisions are solved and coded each by each. So finally, the whole problem will be solved.
Importantly to solve the whole problem subdivisions can be used repeatedly.

Modular Programming

In modular programming, the functionality of the program is done using smaller independent
units. these units are designated to do a specific function. Each module contains all the variables
and data relevant to the function.

Modularization is a best option for large programs.

Multiple programmers code separate modules, which will make the coding productive.

Further modules can be used in other projrcts also, which makes those modules reusable.
Structured Coding

Structured coding is the method of programming extensively using flow controls.

There are two type of flow contols,

Selection structures -If, If-else, Nested If-else, Ternary Operator, Switch Case

Repetetion Structures – For, While, do-While


Object Oriented Programming

As explained in the earlier procedural or structured programming is devided into set of


functions. These functions have bunch of stored data and variables. When the program gets
complex there will be functions all over the place. This is known as spagedi coding. To solve
this issue OOP concepts are used.

In OOP instead of deviding procedures program is seperated around objects. related variables
and functions are combined to a single unit known as an object. Object is a representation of a
item thet the program must handle.

Object is a member of a class. A class specifies the properties of an object. Object behavior is
also described by a class.

There are four main concepts in OOP.

Encapsulation

Abstraction

Inheritance

Polymorphism

Conditional Statements in Programming

A computer program is an algorithm containing set of instructions. That is known as a software.


In order to produce a working software the program itself must know the flow of the program.
For this conditional statements or flow controls are used in programming.

There are two type of flow controls available,

Selection

Selection is a method of controlling the program by selecting what to do next. So definitely


there must be two or more options. To select the proper option conditional statements are made.
These contols are logics, based on different funde,ental logics below selection type control
statemnts are available.
If

If Statement checks whether the condition is true or false. If the condition is true, the code will
be executed.

If-else

In If Statement if only the expression is true. But what if another set of code should run when
the expression is false. If-else is used for that.
Nested If-else

If-else statement can execute two different code segments based on whether test expression is
tru or false. But if there are more possibilities than two, the Nested If-else statement can be
used.

If the first condition is true relevant code segment will run. Else if the second condition is true
relevant code segment will run. Else if the second condition is true relevant code segment will
run. According to that Nested If-else statement will allow to check multiple expressions and
choose one.

Switch Case Statement

In Nested If-else, until the condition become true the selection structure will run. This better
when it is really hard to determine the code segment that needs to run.
But among multiple options, or selections if we know what is the code we need to run exactly
at the beginning, it is better to use switch case statements. Because for this kind of requirement
switch case is proven to be the fastest option to choose.

Ternary Operator

Ternary operator is also a kind of a if-else statement. But instead of writing a lengthy code the
conditions can be checked by a single conditional statement.

But this structure more suitable and readable for short conditions.
Repetition

Instead of just executing the code only once if the statement is true, repetition structures allow
running the code block until the condition becomes false.

This is a loop. Until the condition breaks, the code block will repeat.

There three types repetition structures available.

For

The most important part of a repetition structure is that the programmer must decide how many
times the block must repeat. This will help to stop the loop.

In this case, there are two possibilities,

The programmer exactly knows how many times the code must repeat.

Or when the program is running the number of repetition times could be changed.

If repetition time is known can use the For structure.

If the number of iterations unknown While loop is the most recommended.

A test expression is given. For that expression if the condition is

While

Do While

This is also a while loop. But the difference is the test expression is checked only after the code
block is executed once. If the condition is true code block will repeat again until the condition
become false.

Modularization

Modularization is a concept. That is used to break a complex program into smaller units. These
units are formed based on the procedural aspect of the program. Therefore, mostly these
modules are known as functions.

There are types of functions that can be used in modularization.

1. Pre-Defined Functions (Library Functions)


2. User-Defined Functions
Pre-Defined Functions (Library Functions)

These types of functions are also known as library functions. “Library” is a file where the
keywords and syntaxes of the programming language are stored. Some most common functions
are pre-defined and stored in a library file. Such as cos(x), exp(x), sqrt(x) are already pre-
defined and stored in a library file named <cmath>.

User-Defined Functions

The user of the language, in other words, the programmer, also can define functions. These are
known as user-defined functions.

A programmer can construct a function out of the main body of the program that can be used
whenever needed like a library function.

User-defined functions can be divided into two categories based in their returning type.

Void functions and Value returning functions. This type of function does not return any data
back to the function call. Value-returning functions will return some data back to the function
call.
System Design Specifications

Pseudocode of the system

An algorithm is a process or procedure for solving a problem. It is a set of actions to be


executed and the order in which those actions are to be executed.

Pseudocode is a method of writing the algorithm using normal language. This will be helpful
for the to understand the algorithms of the system easily in order to develop the program.

main ( )

BEGIN

DECLARE VARIABLE AS choice

DISPLAY “********LOGIN**********”

DISPLAY “1. Login”

“2. Signup”

“Enter your choice here:”

INSERT choice

START SWITCH CASE

SET PARAMETER AS choice

IF choice IS 1

FUNCTION CALL login ( )

IF choice IS 2

FUNCTION CALL Signup ( )

ELSE

DEFAULT DISPLAY “Invalid Input”

THEN FUNCTION CALL main ( )

END
Pseudocode for signup ( )

BEGIN

DECLARE VARIABLE AS reguser, regpass

DISPLAY "Enter the username: "

INSERT reguser

DISPLAY "Enter the username: "

INSERT regpass

OPEN TEXT FILE "users.txt"

SAVE reguser, regpass TO TEXT FILE

DISPLAY “Registration is Successful”

DISPLAY “Please 'enter' to login"

THEN FUNCTION CALL login ( )

END
Pseudocode for Login ( )

BEGIN

DECLARE VARIABLES AS exist, user, pass, u, p

DISPLAY "Please enter your username: "

INSERT user

DISPLAY “Please enter your password: "

INSERT pass

OPEN TEXT FILE "users.txt"

START LOOP WHILE

GET DATA u, p FROM TEXT FILE

CHECK WHETHER

u IS user AND p IS pass

IF YES

DISPLAY "Login Successful Welcome!"

END

IF NOT

DISPLAY " Sorry, Login Error. To go back please 'enter'"

FUNCTION CALL main ( )

END
Pseudocode mainMenu ( )

BEGIN

DECLARE VARIABLES AS int choice

DISPLAY

" _*_*__*_*_*__*_SUPREME FURNITURES_*_*__*_*_*__"

" ~~~~~~~~~Operations Management System~~~~~~~~~"

"Please select an option from the below menu"

"1. View Available Furniture"

"2. Update Store Room Data"

"3. Bill a Customer"

"4. Logout"

"Enter your choice here: "

INSERT choice

STAR SWITCH CASE

SET PARAMETER choice

IF choice is 1 FUNCTION CALL viewFurnitures ( )

IF choice is 2 FUNCTION CALL updateStore ( )

IF choice is 3 FUNCTION CALL billCustomer ( )

IF choice is 4 FUNCTION CALL logout ( )

DEFAULT

DISPLAY "Sorry Invalid Input To try again please 'enter'"

IF ‘enter’ FUNCTION CALL mainMenu ( )

END
Pseudocode viewFurniture
BEGIN

DECLARE VARIABLES AS int choice

DISPLAY

"**********View Furnitures**********"

"Please select the item you want to view from below options,"

“1 Tables 4 Wardrobes

2 Chairs 5 Sofas

3 Beds 99 Main menu”

"Please enter your selection here: "

INSERT choice

STAR SWITCH CASE

SET PARAMETER choice

IF choice 1 FUNCTION CALL viewTables ( )

IF choice 2 FUNCTION CALL viewChairs ( )

IF choice 3 FUNCTION CALL viewBeds ( )

IF choice 4 FUNCTION CALL viewWardrobes ( )

IF choice 5 FUNCTION CALL viewSofas ( )

IF choice 99 FUNCTION CALL mainMenu ( )

DEFAULT

DISPLAY "Sorry Invalid Input To try again please 'enter'"

IF ‘enter’ FUNCTION CALL viewFurnitures ( )

END
Pseudocode updateStore

BEGIN

DECLARE VARIABLES AS int choice

DISPLAY

"**********Update Store Room************"

"Please select the item you want to add from below options,"

“1 Table 4 Wardrobe

2 Chair 5 Sofa

3 Bed 99 Main menu”

"Please enter your selection here: "

INSERT choice

IF choice IS 1

FUNCTION CALL insertData(f)

FUNCTION PASSES INSERTED DATA BACK

OPEN TEXT FILE "tables.txt"

SAVE icode, iname, icolor, iqt, iprice TO TEXT FILE

ELSE IF choice IS 2

FUNCTION CALL insertData(f)

FUNCTION PASSES INSERTED DATA BACK

OPEN TEXT FILE "chairs.txt"

SAVE icode, iname, icolor, iqt, iprice TO TEXT FILE


ELSE IF choice IS 3

FUNCTION CALL insertData(f)

FUNCTION PASSES INSERTED DATA BACK

OPEN TEXT FILE " beds.txt"

SAVE icode, iname, icolor, iqt, iprice TO TEXT FILE

ELSE IF CHOICE IS 4

FUNCTION CALL insertData(f)

FUNCTION PASSES INSERTED DATA BACK

OPEN TEXT FILE wardrobes.txt"

SAVE icode, iname, icolor, iqt, iprice TO TEXT FILE

ELSE IF CHOICE IS 5

FUNCTION CALL insertData(f)

FUNCTION PASSES INSERTED DATA BACK

OPEN TEXT FILE “sofas.txt”

SAVE icode, iname, icolor, iqt, iprice TO TEXT FILE

ELSE IF CHOICE IS 99

FUNCTION CALL mainMenu ( )

ELSE

DISPLAY "Sorry Invalid Input To try again please 'enter'"

IF ‘enter’ FUNCTION CALL updateStore ( )

DISPLAY "Item saved successfully"

"To ga back please 'enter'"

IF ‘enter’ FUNCTION CALL updateStore ()

END
Pseudocode billCustomer ( )

BEGIN

DECLARE VARIABLES AS string cxname, cxphone

DECLARE VARIABLES AS float subTotal, iTotal

SET subTotal TO ZERO

DECLARE VARIABLES int size

DISPLAY "Enter customer name: "

INSERT cxname

DISPLAY "Enter customer phone number: "

INSERT cxphone;

DISPLAY “How many items are there for this bill? “

INSERT size

DECLARE STRUCTURED ARRAY VARIABLE Invoice invoice

SET PARAMENTER size FOR THE ARAY

START

FOR LOOP

SET COUNTER ZERO

COUNTER IS LESS THAN size

ADD 1 TO COUNTER

DISPLAY "Enter item code: "

INSERT invoice[i].icode

DISPLAY "Enter item type: "

INSERT invoice[i].itype

DISPLAY "Enter item quantity: "


INSERT invoice[i]. iquantity

DISPLAY "Enter item price: "

INSERT invoice[i]. iprice

DISPLAY "Enter item price: "

INSERT invoice[i]. iprice

CALCULATE

invoice[i].iTotal = invoice[i].iquantity*invoice[i].iprice

subTotal = subTotal + invoice[i].iTotal

END OF THE FOR LOOP

OPEN TEXT FILE “sales.txt”


SAVE cxname, cxphone, subTotal

START

FOR LOOP

SET COUNTER ZERO

COUNTER IS LESS THAN size

ADD 1 TO COUNTER

SAVE invoice[i].icode, invoice[i].itype, invoice[i]. iquantity, invoice[i]. iprice

invoice[i]. iprice, invoice[i].iTotal

END OF THE FOR LOOP

CLOSE TEXT FILE “sales.txt”


DISPLAY

“========INVOICE=========”

"Customer name: "

"Customer phone number: "

"Item_code" "Description" "Quantity" "Unit price" "Item_Total"

START FOR LOOP

SET COUNTER ZERO

COUNTER IS LESS THAN size

ADD 1 TO COUNTER

OUTPUT

invoice[i].icode invoice[i].itype invoice[i].iquantity invoice[i].iprice invoice[i].iTotal

END OF THE FOR LOOP

DISPLAY “Sub Total = Rs.”

OUTPUT subtotal

END
Pseudocode void logout ( )

BEGIN

FUNCTION CALL main ( )

END

Pseudocode viewTables ( )

BEGIN

OPEN TEXT FILE “tables.txt”

DECLARE INPUT SYNTAX input

DECLARE VARIABLES char x, furniture f

.........................Chairs.......................

_______________________________________________________________________

SET INTEND 10 AND DISPLAY

Code | Description | Color | Quantity | Unit price

_______________________________________________________________________

WHILE input IS x

Input ASSIGN VARIABLES

f.icode f.icode f.iname f.icolor f.iqt f.iprice;

SET INTEND 10 AND DISPLAY

f.icode f.icode f.iname f.icolor f.iqt f.iprice;

CLOSE text.file

END
Pseudocode insertData (furniture f)

DISPLAY

_______________________________________________________________________

To add the selected type of new item

Please enter below details,

1. Enter the item code: ";

INSERT f.icode;

DISPLAY

2. Enter item name: ";

INSERT f.iname;

DISPLAY

3. Enter item color: ";

INSERT f.icolor

DISPLAY

4. Enter item quantity available: ";

INSERT f.iqt;

DISPLAY

5. Enter unit price: ";

INSERT f.iprice;

RETURN VALUES OF THE STRUCTURED VARIABLE TO FUNCTION CALLING

END
Software Requirements Specification

Introduction

Supreme Furniture is a famous furniture seller in the city. The management of the company
has decided to implement a software system to manage the main processes of the company.

Purpose

The system could be able to store inventory details and view them, bill customers and print
invoices, and view company details and sales details.

Scope

Currently, the company is not automated. Therefore, the system must be a fundamental
platform. The system must be password protected, must be user-friendly, and easily
accessible. The system must have the capacity to enhance features in the future.

Requirements

Functional Requirements

Company Managers and Owners

1. Log in to the system


2. View Available Furniture
3. Update Available Furniture
4. View Sales Records

Cashier

1. Log in to the system


2. View Available Furniture
3. Bill Customer

Other Functional Requirements are,

• Logout.
• View Company Details.
• Go back through the system
Non- Functional Requirements

A user of the system can log in to the Supreme Furniture Operations Management System
using his/her saved username and password.

The logout option is available on the main menu of the system. Users can walk through the
system using these options by entering the desired choice number.

The system can be used to view available furniture. Furniture can be viewed according to five
categories. Such as Tables, Chairs, Beds, Wardrobes, and Sofas.

If needed new types of items can be added to the system. There is an “update furniture”
option on the main menu.

A customer can be billed using the same system. Multiple items can be added to the customer
bill. According to that, an invoice will be printed.

Sales details are also can be viewed using the system. All the data are saved on a file text file
document.

User details, sales details, and furniture details must be protected by the system. Additionally,
the system must be able to handle a minimum of 100 users at a time. And a cloud database is
much needed for the system to cater to company expansions.
Implementation of the Proposed Solution

Header file used in the system

#include <iostream>

#include <istream>

#include <fstream>

#include <string.h>

#include <string>

#include <iomanip>
Test Plan of the System

Test Test Case Name Scenario Expected Result


Case
ID
01 Main Function Display Options to Option to log in or signup
Login or Signup
02 Signup A new username and Inputs saved and registration
password can be saved successful notification, then run
the login function
Test Case

Test Case ID 01

1 Test Case Main Function


Name
2 Test Case Options to Login or Signup
Scenario
3 Inputs of Menu choice 1 or 2
data
4 Expected Login interface
Result Signup interface
5 Actual
Result

6 Screenshot
7 Conclusio
n

Test Case ID 02

1 Signup
2 A new username and password can be saved
3 Username = “reguser”
Password = “regpass”
4 Registration is Successful
Please 'enter' to login
Login function
5
6
7

You might also like