Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Fundamentals in Programming.: Gehan Chamod Adikari

Download as pdf or txt
Download as pdf or txt
You are on page 1of 60

Fundamentals in

Programming.
Gehan chamod Adikari
CL/HDCSE/93/56
Assignment Cover Sheet

Qualification Module Number and Title


Higher Diploma in Computing and Software CSE 4002
Engineering Fundamentals in Programming

Student Name & No. Assessor


Gehan Chamod – CL/HDCSE/93/56 Vindya Karunarathne
Hand over date Submission Date
Xx.xx.xxxx xx.xx.xxxx
Assessment type Duration/Length of Weighting of Assessment
Assessment Type
Report and Software
Coursework Submission 100%
(3000 words)

Learner declaration

I, ………………………………………….<name of the student and registration number>,


certify that the work submitted for this assignment is my own and research sources are fully
acknowledged.

Marks Awarded
First assessor

IV marks

Agreed grade

Signature of the assessor Date

1
FEEDBACK FORM
INTERNATIONAL COLLEGE OF BUSINESS & TECHNOLOGY
Module : CSE 4002
Student :
Assessor : Vindya Karunarathne
Assignment : FP

Strong features of your work:

Areas for improvement:

Course Work and Practical Assessment

This assignment is worth 100% of the overall assessment for this module.

2
Learning outcomes covered
LO1. Explain structured programming concepts
LO2. Design a basic structured computer program
LO3. Developed a modularized computer programme for a prepared design
LO4. Compile software testing and documentation

Scenario
BestMeal is a newly built Meal kit restaurant situated in west London. This restaurant is
famous for their consistently excellent recipes with quality ingredients.
Responding to rapid customer growth, management has decided automate the entire business
process. Initial step BPA (business process automation) team have analyzed the business
process and planned to automate the Meal kit ordering process.
Assume that you are a group member of BestMeal business process automation team.
Design and develop the Meal kit-ordering module for BestMeal Restaurant automation.

Main requirements
 Manage available Meal kits
 View available Meal kits.
 Search specific Meal kit.
Other requirements are.
 User login.
 Logout.
 Exit
 Help

Note that: Refer the following link to get an idea https://www.homechef.com


Create an error free, effective one with user-friendly interfaces, appropriate messages, outputs
and menu driven application using C++ programming language. Students can use appropriate
data structures and text files to store information.

Carefully investigate the given scenario and provide the proposed solution.Attach
softcopy of error free program with your documentation.Keep all the backups
3
TASKS

Task 01 – Programming methodology (LO1) -Report


Describe the usage of basic programming methodology such as controlling structures
(selection, repetition) and modularization.
 Provide appropriate examples. (10 marks)

Task 02 - System Design (LO2) -Report


Identify the requirements of the system to be implemented and produce detailed
requirements specification. Design flow charts according to the SRS.
 Use appropriate modularization to reduce the complexity of the design. (20 marks)

Task 03 – System Implementation (LO3) - Software submission


Implement a functional C++ program to meet the requirements given in the specification, by
following the design created above. (40 marks)

Task 04 - System Testing and Documentation (LO4) -Report


Produce proper testing documentation including test plan, test cases and test results. Conduct
user acceptance testing and provide feedback with sample questionnaires used.
 Proper standard documentation need to be followed throughout the report and
language need to be used accordingly. (30 marks)

4
Acknowledgement

This research was supported by the International College of Business & Technology (ICBT).
I would like to express my deepest gratitude to my lecturer, Miss Vindya Karunarathne, who
assisted and guided throughout this assignment. Special thanks should also go to my parents
and all the colleagues of my batch for sharing information.
Thank you,

Adikari Mudiyansalage Gehan Chamod Adikari,

(CL/HDCSE/93/56).

5
Contents
Acknowledgment
Introduction
Contents
Task 01
1.1 Introduction to programming
1.2 Programming Methodologies
1.3 Controlling Structures
1.4 Modularization
1.5 Library Functions
1.5 User Defined Functions

Task 02
2.1 Requirements gathering techniques
2.2 System Requirements Specification document for Pharmacy Automated Billing
System
2.3 Flow chart diagram
2.4 Pseudocodes for above diagrams

Task 03
3.1 Code Explanation
3.2 Repetition and controlling structures

Task 04
4.1 Test plan
4.2 Test cases
References

6
Task 01
1.1 Introduction to Programming

Programming is writing computer code to create a program, to solve a


problem. Programs are created to implement algorithms. Algorithms can be represented
as pseudo code or a flowchart, and programming is the translation of these into a computer
program.

To tell a computer to do something, a program must be written to tell it exactly what to do


and how to do it. If an algorithm has been designed, the computer program will follow this
algorithm, step-by-step, which will tell the computer exactly what it should do.

1.2 Programming Methodologies


Two main types of Programming methodologies;

1. Structured Oriented Programming

2. Object Oriented Programming

3. Principles of object oriented Programming

1.2.1 Structured Oriented Programming


Structured Programming is designed which focuses on process / logical structure and then
data required for that process. This also follows top-down approach. Here the Programs are
broken into small self-contained functions. As there is no way of data hiding it becomes less
secure in structured oriented programming. Modular programming can also moderately solve
complex programs. But it’s very unlikely to be reusable, more function dependency.
However, this method is less abstraction and flexible.

1.2.2 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. Object Oriented Programming
is designed which focuses on data and has a Bottom up approach. These Programs are

7
divided into small entities called objects, as there are ways of data hiding it becomes more
secure. These Can solve any complex programs, while providing more chances of reusability
and less function dependency. Object Oriented Programming also supports inheritance,
encapsulation, abstraction, polymorphism.

1.2.3 Principles of object Oriented Programming.

 Abstraction

This concept shows only the necessary things, here you don’t want to show how you have
implemented some function.
 Encapsulation
Encapsulation is the mechanism of hiding of information implementation by restricting
admission to public methods. Instance variables are saved private and accessor
techniques are made public to obtain this.

 Inheritance

Inheritances expresses “is-a” relationship between two objects.

8
 Polymorphism
A programming language's potential to process objects in another way relying on their
data type or class.

1.3 Controlling Structures


In computer programming controlling structures are important, because if the
programmer wants to do some modifications to the go with the flow of
the computer application controlling structures will be used for this part.
A control structure determines the order in which statements are executed. There are
two classes in controlling structure basically,

 Selection Structures.

 Repetition Structures.

1.3.1 Selection Structures


The selection structures that will be discussed are as follows,

o IF Statement

o IF else

o Nested else if

o Ternary / Conditional Operator

o Switch Case

IF Statement
This statement helps you to control the flow of your program, by taking decisions on which
code to perform. This statement permits you to control if a program enters a section of code
or not based on a given condition is true or false. Thus it allows the program to choose an
action based upon the user's input.

9
IF else
When there is a situation and you need to perform a block of code if condition is true and
perform another piece of code if the same condition is false. This can be done in C++ using
the if-else statement.

Nested else if
10
When there is an if statement inside another if statement then it is called the nested else if
statement.

Ternary / Conditional Operator


The conditional (ternary) operator is the only JavaScript operator that takes three operands: a
condition followed by a question mark (?), then an expression to execute if the condition is
truth followed by a colon (:), and finally the expression to execute if the condition is falsy.
This operator is frequently used as a shortcut for the if statement. The Ternary operator in
C++ is often called as the shorted to the simple if and else.

Switch Case
This statement is used when we have multiple conditions and need to execute dissimilar
action based on the condition. When we have multiple conditions and we have to perform a
block of statements when a certain condition is fulfilled. In this event case we use an easy
method called switch case.

11
1.3.2 Repetition Structures

For Loop
Until the needed conditions are fulfilled, a for loop is used to execute a block of statements.
Refer the below example-
When displaying number 1-10 you may want to set the value of a variable to 1 and display it
10 times, increasing its value by 1 on each loop iteration.

12
While Loop
Here, until the condition returns false it is evaluated to check if it’s true. When condition
returns false, the control comes out of loop and jumps to the next statement in the program
after while loop. The Combining interactive data entry with the repetition capabilities of the
while statement produces very adaptable and powerful programs.

Do while loop
The condition gets evaluated after the statement inside the loop is executed if the condition
returns true then the control goes to the “do” more recurrent execution of it, this will
happen recurrently till the condition returns false. As soon as the condition returns
false control jumps to the next statement in the program after do-while.

13
1.4 Modularization.
Modular programming or modularization is the technique of subdividing a PC software into
separate sub-programs to amplify the maintainability, readability of the code and to make
the application available to make any modifications in future or to rectify the errors.

1.4.1 Advantages of Modularization.


The advantages of practicing modular programming are many. These include writing less
code in which one singular procedure can be enhanced for reuse terminating the requirement
to rewrite the code multiple times. Further, these coding programs can be outlined in a more
practical approach simply because be one singularly isolated unit only handles a small section
of the entire code. Furthermore, modular programming permits multiple programmers to
integrate working on the same application. Moreover, the code is preserved across multiple
files and is short in nature and is easily understandable. Errors can also easily be
distinguished, as they are confined to a subroutine or function. Also, this code can be applied
in multiple applications and the scoping of variables can also be easily controlled.

1.5 Library Functions.


The C++ Library c performs common mathematical calculations, string manipulations,
character manipulations, input/output, error checking and various further convenient
operations. This makes the programmer's job easier, because these functions provide many of
the capabilities programmers need.

The Standard Function Library in C++ is what keeps you from having to rewrite even the
easiest of programming instructions. It is like a big library of sub-libraries, each that consists
the underlying code for several functions. In order to make use of these libraries, you link to
each library in the broader library through the use of header files.

A few examples of header files are shown in the below table,

14
Functions Description Examples
iostream Input and output function. Controls for input and output

cmath Math function. Mathematical formulas (such as trig


and exponents)
ctime Date and time function. running time\clock\time
calculations/conversions
cstdlib Miscellaneous utilities Memory allocation\numeric string
conversion\pro
cstring String function. Create string variables\compare
strings
cstdio Standard I/O function Controls for input and output

exception Exception handling tools Trap exceptions, which helps prevent


program crashes.

1.5.1 User Defined Functions


A user defined function is a function which is declared and defined by the user himself.
While writing programs, if there are no available library functions for performing a particular
task, we write our own function to perform that task. Example for user defined function
is main function.

15
Task 02
2.1 Requirements gathering techniques.

To gather requirements for this billing application I have implemented the process of
distributing close ended type questionnaire among the daily customers that visit the restaurant
and the employees that work in Best Meal restaurant. They’re supposed to reach the
questions and tick the answer that they think is most suitable,

Agree Neutral Disagree

Manual billing is delayed beyond the


right or expected time.

Manual billing provides a margin for


multiple human errors.

An automated billing system is


highly secured .

Employees need have a basic IT


knowledge .

In an automated billing system


products can be identified easily.

An automated billing system is


highly confidential to customer.

An automated billing system is


highly confidential to customer

16
2.2 System Requirements specification document
for Restaurant Automated Billing System.

2.2.1 Introduction
Best Meal is a newly built Meal kit restaurant situated in west London. This restaurant is
famous for their consistently excellent recipes with quality ingredients.
Responding to rapid customer growth, management has decided automate the entire business
process. This restaurant system should be made in order to automate the previously manually
done processes of viewing available meal kit, Manage available Meal kits , Search specific
Meal kit.

2.2.2 Purpose System.


After conducting our research and the results of the questionnaire I was able to analyze the
present system and figure out the problems of the existing manual system.

In which I identified, its inability to modify data, it further failed to be user friendly, which
would lead to a difficulty in reports generation. This would provide more levy for
Mathematical and human errors and will also result in loads of paper work and loss of
information. It further showed an inability of sharing data. Moreover, did not support in
decision making. Due to the above reasons we have decided to go ahead with a restaurant
automated billing system as it will help to collect and analyze all the data that is entered into
the system by the cashier and it will print an automatic bill for the meal kit that the customer
will purchase.

2.2.3 Scope

 The project will help the cashier in fast billing.


 Easy to maintain in future prospect.
 This project enable to see view available Meal kits.
 This project enable to see meal kits detailed sales report.

17
2.2.4 Functional Requirements.
All the features required in a system in order to not be destined to disappoint the customer’s
basic requirements. This is the complete collection of both the functional and non-functional
requirements. Typically, functional requirements are the basic behavior of a system, its main
features and functions.

Functional Requirements for Administrator

o View list of meal kit


-The admins should be able to view the meal kit name and the meal kit price.

o Add recipes to the list of meal kit.


-The admins should be able to add meal recipes at one go to the system.

Functional Requirements for Cashier

o View list of meal kit


-The Cashier should be able to view the meal kit name and the meal kit price.

o Select items and print bill


-The cashier should be able to select one food type and then input the quantity for that type
and the bill should print accordingly.

2.2.5 Non- Functional Requirements.

Usability Requirement
• The system will enable the employees to get to the system from a PC
application which will be used as an interface, no extraordinary training is
required since all employees know about the general use of PC
applications. The system is easy to use which makes the system simple.

18
• In order to make it user friendly include guiding messages to certain
function which will allow the user to do the functionality properly by
minimizing the errors which can occur in the functions of software.
Availability Requirement
• The system available for the employees except to give offers. The system
shall be operational 14 hours a day and 7 days a week.
Efficiency Requirement
• In terms of efficiency as this is a command line- based system it has a high
efficiency which allows the user to work quickly with the system. And in
order to maximize performance do not include time delays in the software.
Accuracy
• The system should accurately provide real time information taking into
consideration various concurrency issues.
• In order to ensure accuracy, we have only allowed the administrator to
perform the changing of entries which is used to provide information to the
customers, so the information provided by the system will be accurate
according to the data given by the administration.
Reliability
• In order to establish reliability, measures should be taken to prevent
crashing of the software which in turn will increase reliability.

19
2.3 Flow chart diagram
2.3.1 Login for admin account

20
2.3.2 Login for cashier account

21
2.3.3 View items for cashier

22
2.3.4 View item for admin

23
2.3.5 Add item for admin

24
2.3.6 Exit function for admin

25
2.3.7 Exit function for cashier

26
2.3.8 Select and print payment bill for cashier account

27
2.4 Psudocodes for above diagrams

2.4.1 View items for admin account


Begin
String productname, pprice
Create ‘csv’ file named “meds.csv”
Enter PRODUCTNAME and PRODUCTPRICE as header
If read row ‘yes’
Display data from the ‘csv’ file
Else
Stop

2.4.2 View items for cashier account

Begin
String productname, pprice
Create ‘csv’ file named “meds.csv”
Enter PRODUCTNAME and PRODUCTPRICE as header
If read row ‘yes’
Display data from the ‘csv’ file
Else
Stop

2.4.3 Add items for admin account

28
Begin
Open ‘csv’ file “Rest.csv”
String productname, pprice
Enter PRODUCTNAME and PRODUCTPRICE as header
Add entered data to the csv file
Display “Item added successfully”
Stop

2.4.4 Login for admin account

Begin
Enter username and password
If username and password correct
If yes
Display “Welcome Admin!”
Display admin account interface
Else
Display “Invalid username or password”
Stop

2.4.5 Login for cashier account

Begin
Enter username and password
If username and password correct
If yes
Display “Welcome Cashier!”
Display cashier account interface
Else
Display “Invalid username or password”
Stop

29
2.4.6 Exit for admin account

Begin
Enter Yes/No
If Yes
Close system
Else
Return to admin menu
Stop

2.4.7 Exit for cashier account

Begin
Enter Yes/No
If Yes
Close system
Else
Return to cashier menu
Stop

30
Task 03
3.1 Code Explanation
3.1.1 Login function
Administrator of the restaurant and the cashier of the restaurant can enter this system. They
have separate passwords and accounts with unique features. The cashier can only select meal
kit and print a bill for the customer while the admin can add new food to the system as well.

31
3.1.2 View items
The cashier and the admin both have the facility of viewing the products. These products are
saved in a comma separated file while is extracted from an excel sheet. This function is
useful for the administrator to see his products at one glance and also helps the cashier to
view the items before printing the bill.

32
3.1.3 Select and print bill
The cashier has get admission to print the price bill. All he/she has to do is to add
the specific product code from the list, and the item will mechanically appear on screen.
Then entering the required quantity of the product and the system will subsequently calculate
the sub total.

33
3.1.4 Exit
Here the administrator and the cashier wants to exit the application they can use this function.

They can confirm if they want to exit or not by typing either “yes” or “no”

34
3.2 Repetition and controlling structures.
3.2.1 Switch case conditions
Switch case statement is used when we have multiple conditions and we need to execute a
block of statements when a particular condition is satisfied.

Ex- view items, log out and exit is printed from 1-4

35
3.2.2 Do while and If-else conditions

36
Task 04
4.1Test Plan
Test Case ID Test Case Name Scenario Result

Test 01 Admin login function Enter correct with Show the Admin
password login interface to the
user

Test 02 Admin login function Enter incorrect Display incorrect


password password

Test 03 1st function in admin Display the list of Show all Meal Kits
login Meal Kit to admin

Test 04 2nd function in admin Admin Section Show all admin


login section

Test 05 3rd function in admin Logout from admin Logout from the
login account admin account

Test 06 Admin login Display Main Menu Show main menu

Test 07 1st function in admin Enter invalid number Show error message
login

Test 08 2nd function in admin Enter invalid number Show error message
login

37
Test 09 3rd function in admin Enter invalid number Show error message
login

Test 10 New Meal Kit no Entering the new Show enter meal kit
meal kit no no message

Test 11 New meal kit Entering the new Show enter meal kit
quantity meal kit quantity quantity message

Test 12 New meal kit price Entering the new Show enter meal kit
meal kit price price message

Test 13 Item added Display meal kit Meal kit should be


added successfully added in the list

Test 14 Exit admin account Enter yes or no to the the program will stop
confirm message

Test 15 Added new meal kit Display new meal kit Added menu list
menu menu

Test 16 Added new meal kit Display meal kit Meal kit should be
menu menu successfully added in the menu list

Test 17 Cashier login function Enter correct Show the Cashier


password login interface to the
user
Test 18 Cashier login function Enter incorrect Display error message
password as invalid password
with the number of
attempts
Test 19 1st function in Cashier Display the list of Display the list of
login meal kits Meal kit

38
4.2 Test Case
Test case Test 01
ID

Test Admin login


Function

Test data Admin password “1234567”


input

Results Display interface for admin

Screenshot

Conclusion Code functioning

39
Test case Test 02
ID

Test Admin Login


Function

Test data Admin password “1234567”


input

Results Display please enter password

Screenshot

Conclusion Code functioning

40
Test case Test 03
ID

Test 1st function in admin login


Function

Test data Enter number 1


input

Results Display Meal Kit list

Screenshot

Conclusion Code functioning

41
Test case Test 04
ID

Test 2st function in admin login


Function

Test data Enter number 2


input

Results Display Admin section

Screenshot

Conclusion Code functioning

42
Test case Test 05
ID

Test 3st function in admin login


Function

Test data Enter number 3


input

Results Display “Exit”

Screenshot

Conclusion Code functioning

43
Test case Test 06
ID

Test admin login


Function

Test data Enter main menu


input

Results Display main menu

Screenshot

Conclusion Code functioning

44
Test case Test 07
ID

Test 1st function in admin login


Function

Test data Enter number 4


input

Results Show error message

Screenshot

Conclusion Code functioning

45
Test case Test 08
ID

Test 2st function in admin login


Function

Test data Enter number 4


input

Results Show error message

Screenshot

Conclusion Code functioning

46
Test case Test 09
ID

Test 3st function in admin login


Function

Test data Enter number 4


input

Results Show error message

Screenshot

Conclusion Code functioning

47
Test case Test 10
ID

Test New meal kit no


Function

Test data Enter a meal kit no


input

Results Display enter meal kit no

Screenshot

Conclusion Code functioning

48
Test case Test 11
ID

Test New meal kit quantity


Function

Test data Enter a meal kit quantity


input

Results Display enter meal kit quantity

Screenshot

Conclusion Code functioning

49
Test case Test 12
ID

Test New meal kit price


Function

Test data Enter a meal kit price


input

Results Display enter meal kit price

Screenshot

Conclusion Code functioning

50
Test case Test 13
ID

Test New meal kit


Function

Test data No input


input

Results Display meal kit add successfully

Screenshot

Conclusion Code functioning

51
Test case Test 14
ID

Test Exit admin account


Function

Test data Enter ‘yes’ to the confirmation message


input

Results Display confirm exit

Screenshot

Conclusion Code functioning

52
Test case Test 15
ID

Test Add new meal kit menu


Function

Test data Enter add new meal kit menu


input

Results Display enter new meal kit menu

Screenshot

Conclusion Code functioning

53
Test case Test 16
ID

Test Add new meal kit menu


Function

Test data No input


input

Results Display enter new meal kit menu successfully

Screenshot s

Conclusion Code functioning

54
Test case Test 17
ID

Test Cashier login function


Function

Test data Enter password “12345678”


input

Results Show cashier menu

Screenshot s

Conclusion Code functioning

55
Test case Test 18
ID

Test Cashier login function


Function

Test data Enter incorrect password


input

Results Show “Invalid Password”

Screenshot

Conclusion Code functioning

56
Test case Test 19
ID

Test 1st function in Cashier login


Function

Test data Enter number 1


input

Results Display meal kit list

Screenshot

Conclusion Code functioning

57
References
Webopedia.com. (2019). What is Object-Oriented Programming? Webopedia
Definition. [online] Available at:
https://www.webopedia.com/TERM/O/object_oriented_programming_OOP.html

https://www.facebook.com/bbc (2019). BBC - Home. [online] BBC Homepage.


Available at: https://www.bbc.co.uk/.

Medium. (2018). Medium. [online] Available at: https://medium.com/.

MDN Web Docs. (n.d.). MDN Web Docs. [online] Available at:
https://www.developer mozilla.org [Accessed 14 Jan. 2021].

Cnx.org. (2021). Repetition Statements, Arrays and Structured Programming.


[online] Available at: https://archive.cnx.org/contents/c00c2405-d597-43ec-a11a-
c6542906cdc0%401/repetition-statements-arrays-and-structured-programming
[Accessed 14 Jan. 2021].

www.softwaretestinghelp.com. (n.d.). Library Functions In C++. [online] Available


at: www.softwaretestinghelp.com. (n.d.). Library Functions In C++. [online]
Available at: https://www.softwaretestinghelp.com/library-functions-in-cpp/
[Accessed 14 Jan. 2021]./library-functions-in-cpp/ [Accessed 14 Jan. 2021].

58
.

59

You might also like