Algorithms & Programming: Building a Library Management System, Study notes of Marketing

A comprehensive introduction to algorithms, exploring their definition, types, and characteristics. It then delves into the software development life cycle (sdlc), outlining its phases and importance in software development. The document further demonstrates the practical application of algorithms by presenting a c# program designed to manage books in a library. This program includes features for adding books, displaying all books, finding books with the least quantity, and identifying books with the highest prices. The document also includes test cases to validate the program's functionality.

Typology: Study notes

2023/2024

Uploaded on 10/24/2024

hugger
hugger 🇺🇸

4.8

(12)

916 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Algorithms and Programming:
Solving Business Problems
Introduction
Algorithms have existed for a long time, and they have become increasingly
important in the modern era of technology and computing. Algorithms help
solve problems in various fields, from mathematics and science to software
development. In this assignment, I will present the concept of algorithms,
provide examples of algorithms in life, and demonstrate how to solve a small
problem using algorithms, diagrams, and the C# programming language.
1. Overview of Algorithms
1.1. Definition of Algorithms
An algorithm is a method, formula, or a specific finite-step procedure for
solving a problem that is based on performing a series of specified actions. A
computer program can be thought of as a complex algorithm. In
mathematics and computer science, an algorithm is a short process that
solves a recurring issue. The term "algorithm" is derived from the name of a
mathematician, Mohammed ibn-Musa al-Khwarizmi, who lived between 780
and 850 and was a member of Baghdad's royal court. Al-Khwarizmi's work is
also the most likely origin of the term "algebra."
1.2. Examples of Algorithms
There are many different types of algorithms, including:
Numerical algorithms
Algebraic algorithms
Geometric algorithms
Sequential algorithms
Operational algorithms
Theoretical algorithms
Some algorithms are named after the mathematicians who invented them,
such as Shor's algorithm and the Girvan-Newman algorithm. Other
algorithms are named after the specific problem they solve, like the
bidirectional search algorithm and the k-way merge algorithm.
1.3. Example of an Algorithm
Let's consider the problem of finding the second-largest value among 10
integer numbers entered from the keyboard. Here's the algorithm to solve
this problem:
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Algorithms & Programming: Building a Library Management System and more Study notes Marketing in PDF only on Docsity!

Algorithms and Programming:

Solving Business Problems

Introduction

Algorithms have existed for a long time, and they have become increasingly important in the modern era of technology and computing. Algorithms help solve problems in various fields, from mathematics and science to software development. In this assignment, I will present the concept of algorithms, provide examples of algorithms in life, and demonstrate how to solve a small problem using algorithms, diagrams, and the C# programming language.

1. Overview of Algorithms

1.1. Definition of Algorithms

An algorithm is a method, formula, or a specific finite-step procedure for solving a problem that is based on performing a series of specified actions. A computer program can be thought of as a complex algorithm. In mathematics and computer science, an algorithm is a short process that solves a recurring issue. The term "algorithm" is derived from the name of a mathematician, Mohammed ibn-Musa al-Khwarizmi, who lived between 780 and 850 and was a member of Baghdad's royal court. Al-Khwarizmi's work is also the most likely origin of the term "algebra."

1.2. Examples of Algorithms

There are many different types of algorithms, including:

Numerical algorithms Algebraic algorithms Geometric algorithms Sequential algorithms Operational algorithms Theoretical algorithms

Some algorithms are named after the mathematicians who invented them, such as Shor's algorithm and the Girvan-Newman algorithm. Other algorithms are named after the specific problem they solve, like the bidirectional search algorithm and the k-way merge algorithm.

1.3. Example of an Algorithm

Let's consider the problem of finding the second-largest value among 10 integer numbers entered from the keyboard. Here's the algorithm to solve this problem:

Input : 10 integers entered from the keyboard Output : The second-largest value in the sequence

Algorithm Solving Process : 1. Start 2. Declare variables MAX and MAX2, and an array B[10] 3. Set MAX to 0 4. For i from 0 to 9 (length of array B), repeat steps 5-6 - Read B[i] - If B[i] > MAX, set MAX = B[i] 5. Read MAX 6. Set MAX2 to 0 7. For i from 0 to 9 (length of array B), repeat steps 8-9 - Read B[i] - If B[i] > MAX2 and B[i] < MAX, set MAX2 = B[i] 8. Print MAX2 9. Stop

The flowchart for this algorithm is provided below:

2. Characteristics of Algorithms

Algorithms have the following key characteristics:

Input : Each algorithm requires one or more input values to execute. Output : Each algorithm produces one or more output values as a result of the computation. Finiteness : An algorithm must terminate after a finite number of steps. Precision : The algorithm must be precise and unambiguous, with each step clearly defined. Generality : An algorithm should be applicable to a wide range of problems, not just specific ones. Objectivity : Regardless of who implements the algorithm or how it is implemented, it should always produce the same result.

3. Software Development Life Cycle (SDLC)

3.1. Definition

The Software Development Life Cycle (SDLC) is a conceptual framework used in project management that describes all the processes involved in a software development project, from planning to maintenance. The SDLC model typically includes the following phases:

Ideation and planning Requirements gathering Design and prototyping Software development Testing and integration Implementation and deployment Operation and maintenance

Depending on the scale and complexity of the project, some project managers may combine, divide, or eliminate certain steps.

Flowchart of the "Find the second-largest value" algorithm

stable and optimal operation. During this period, the software will be increasingly upgraded and improved, and maintenance will help find and fix any bugs to ensure a good user experience.

Conclusion

In this assignment, I have provided an overview of algorithms, including their definition, examples, and a specific algorithm to find the second-largest value among 10 integers. I have also discussed the characteristics of algorithms and the Software Development Life Cycle (SDLC), which is a crucial framework for building software applications. By understanding algorithms and the SDLC, developers can effectively solve problems and create high-quality software solutions.

References

Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to Algorithms. MIT Press. Knuth, D. E. (1997). The Art of Computer Programming, Volume 1 (3rd ed.). Addison-Wesley. Sedgewick, R., & Wayne, K. (2011). Algorithms (4th ed.). Addison- Wesley. Sommerville, I. (2015). Software Engineering (10th ed.). Pearson.

Implementing a Library Management System

1. Introduction

The given text describes the implementation of an algorithm to solve a problem faced by a library manager. The goal is to create a program that can manage books in the library, including printing out all the books entered, the books with the least quantity, and the books with the highest prices.

2. Problem Statement

A library wants to manage books in the library. The library manager needs to print out all books entered, the books with the least quantity, and the books with the highest prices. The program needs a main menu based on requirements such as: - Enter the book code - Enter the title of the book - Enter the number of books - Enter the bookshelf

3. Approach

To solve this problem, the author will use the C# programming language and apply the concepts learned from "Procedural Programming", including the use of libraries, variables, expressions, loop statements, and conditional statements.

4. Input and Output

Input: - Book code - Book title - Quantity of the book - Price of the book

Output: - Information of all imported books - Information of the books with the least quantity - Information of the books with the highest price

5. Data Structures

The program will use the following data types and arrays:

Data Types: - int: option, min, n, num, i - float: highest

Arrays: - int: code[], quantity[] - string: name[] - float: price[]

6. Use-Case Diagram

The use-case diagram provided in the text shows the main functionalities of the program, which include: 1. Input book information 2. Print all book information 3. Print the books with the least quantity 4. Print the books with the highest price 5. Exit the program

7. Flowcharts

The text includes several flowcharts that explain the step-by-step implementation of the algorithm:

7.1. Main Program Flow: 1. Display the main menu 2. Accept user input for the selected option 3. Perform the corresponding operation based on the selected option 4. Repeat steps 1-3 until the user chooses to exit the program

7.2. Input Book Information: 1. Accept the number of books to be entered

  1. Iterate through the number of books and accept the book code, title, quantity, and price 3. Update the total number of books in the program

7.3. Print Book Information: 1. Iterate through the list of books and print the book code, title, quantity, and price

7.4. Print the Least Quantity Book: 1. Assign the first book's quantity as the minimum 2. Iterate through the list of books and update the minimum quantity if a lower value is found 3. Print the information of the book with the least quantity

7.5. Print the Highest Price Book: 1. Assign the first book's price as the highest 2. Iterate through the list of books and update the highest price if a higher value is found 3. Print the information of the book with the highest price

displayed on the screen. Actual Outcome: All the book's information (code, name, quantity, price) has been displayed on the screen. Pass or Fail: Pass

Test Case 4: Display the Least Quantity Book

What is being tested? The program should display the information of the book with the least quantity. Expected Outcome: The information of the book with the least quantity has been displayed on the screen. Actual Outcome: The information of the book with the least quantity has been displayed on the screen. Pass or Fail: Pass

Test Case 5: Display the Highest Price Book

What is being tested? The program should display the information of the book with the highest price. Expected Outcome: The information of the book with the highest price has been displayed on the screen. Actual Outcome: The information of the book with the highest price has been displayed on the screen. Pass or Fail: Pass

Test Case 6: Exit the Program

What is being tested? The program should automatically end and exit when the user selects the corresponding option. Expected Outcome: The program has been automatically ended and exited. Actual Outcome: The program has been automatically ended and exited. Pass or Fail: Pass

Test Case 7: Invalid Option

What is being tested? The program should display a request to re-enter a valid option if the user selects an invalid option. Expected Outcome: The program displays "Enter your option again" and displays the main menu again. Actual Outcome: The program displays "Enter your option again" and displays the main menu again. Pass or Fail: Pass

Test Case 8: Add Multiple Books

What is being tested? The program should prompt the user to input the information for multiple books until the desired number of books has been reached. Expected Outcome: The program prompts the user to input the information for each book until the desired number of books has been reached. Actual Outcome: The program prompts the user to input the information for each book until the desired number of books has been reached. Pass or Fail: Pass

Test Case 9: Store Book Information (Book 1)

What is being tested? The program should store the book's code, name, quantity, and price into the respective arrays. Expected Outcome: The book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Actual Outcome: The

book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Pass or Fail: Pass

Test Case 10: Store Book Information (Book 2)

What is being tested? The program should store the book's code, name, quantity, and price into the respective arrays. Expected Outcome: The book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Actual Outcome: The book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Pass or Fail: Pass

Test Case 11: Store Book Information (Book 3)

What is being tested? The program should store the book's code, name, quantity, and price into the respective arrays. Expected Outcome: The book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Actual Outcome: The book's code, name, quantity, and price have been stored into the code[i], name[i], quantity[i], and price[i] arrays, respectively. Pass or Fail: Pass

Test Case 12: Display All Books (After Adding)

What is being tested? The program should display all the book's information (code, name, quantity, price) stored in the arrays. Expected Outcome: All the book's information (code, name, quantity, price) has been displayed from the code[i], name[i], quantity[i], and price[i] arrays. Actual Outcome: All the book's information (code, name, quantity, price) has been displayed from the code[i], name[i], quantity[i], and price[i] arrays. Pass or Fail: Pass

Test Case 13: Display the Least Quantity Book (After Adding)

What is being tested? The program should display the information of the book with the least quantity. Expected Outcome: The information of the book with the least quantity has been displayed: Code: 111, Name: fairy tales, Quantity: 20, Price: 6.5. Actual Outcome: The information of the book with the least quantity has been displayed: Code: 111, Name: fairy tales, Quantity: 20, Price: 6.5. Pass or Fail: Pass

Test Case 14: Display the Highest Price Book (After Adding)

What is being tested? The program should display the information of the book with the highest price. Expected Outcome: The information of the book with the highest price has been displayed: Code: 112, Name: history, Quantity: 10, Price: 9.5. Actual Outcome: The information of the book with the highest price has been displayed: Code: 112, Name: history, Quantity: 10, Price: 9.5. Pass or Fail: Pass