0% found this document useful (0 votes)
98 views14 pages

Min Thukha Kyaw (Assignment 1)

The document defines algorithms and outlines the process of building an application. It provides an explanation of algorithms and how they work. It also gives an example algorithm of a simple calculator and analyzes the process of writing code for an application.

Uploaded by

Sai Aung Mainn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views14 pages

Min Thukha Kyaw (Assignment 1)

The document defines algorithms and outlines the process of building an application. It provides an explanation of algorithms and how they work. It also gives an example algorithm of a simple calculator and analyzes the process of writing code for an application.

Uploaded by

Sai Aung Mainn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Programmed Title : Diploma in Computing

Learner’s name : Min Thukha Kyaw

Learner’s ID No : RF37178

Unit No :1

Unit Title : Programming

Assignment No : 1 of 3

Assignment Title : Definition of basic algorithm and process of programming

Date of submission : 27. 8.2023

1
Table of Contents
1. Algorithm................................................................................................................................................................ 3
1.1 Explanation of algorithm.........................................................................................................................................3
1.2 Outline of the Process in Building an application:................................................................................................3
1.3 how does the algorithm work?...............................................................................................................................5
1.4 Example of Algorithm for a Simple Calculator:......................................................................................................5
1.5 Determine the steps taken from writing code to execution......................................................................................6
1.6 Analyses the process of writing code.......................................................................................................................8
1.7 Process of writing code Calculator..........................................................................................................................9
1.8 relationship between the written algorithm and the code variant..........................................................................10
References........................................................................................................................................................................12

2
1. Algorithm
An algorithm is a method for doing calculations or finding solutions to issues. Algorithms are
precise instructions that carry out preset activities consecutively in either hardware- or software-
based routines. (Anon., 2021)

1.1 Explanation of algorithm


An algorithm is a detailed collection of guidelines or rules that specify how a certain activity or
issue can be resolved. It acts as a guide for resolving issues or reaching particular objectives. A
fundamental idea in computer science, algorithms are employed in many contexts, including the
development of software applications. (Anon., 2021)
Algorithms play a big role in information technology across the board. In mathematics and
computer science, an algorithm is often referred to as a straightforward method that solves a
recurrent problem. Automated systems require algorithms because they provide the guidelines for
data processing. (Anon., 2021)
An algorithm may be used for simple tasks like sorting lists of numbers or for more difficult
ones like recommending user content on social media. An algorithm's initial input and computational
instructions are frequently given. After the computation is complete, an output is produced. (Anon.,
2021)
1.2 Outline of the Process of Building an Application:

Building an application involves several stages, from conceptualization to development, testing, and
deployment. Here is an outline of the process:

Define the Problem:

Clearly define the problem or need that the application will address. Understand the
requirements, constraints, and objectives.

Conceptualization:

Brainstorm ideas and concepts for the application's functionality and user interface. Create a
high-level overview or concept document.

Requirements Gathering:

Collect detailed requirements from stakeholders and end-users. Document functional and
non-functional requirements.

Design:

Create a detailed design of the application, including user interfaces, data structures, and
system architecture. Consider user experience (UX) and user interface (UI) design. Develop
wireframes, mockups, or prototypes.

Planning:

3
Create a project plan, including timelines, milestones, and resource allocation. Define the
technology stack and development tools to be used.

Development:

Write the code for the application based on the design and requirements. Follow best coding
practices and coding standards. Implement features, algorithms, and data storage.

Testing:

Perform various types of testing, including unit testing, integration testing, and user
acceptance testing (UAT). Identify and fix bugs and issues. Ensure the application meets the defined
requirements.

Deployment:

Prepare the application for deployment to the target environment (e.g., servers, app stores).
Set up databases, servers, and hosting infrastructure. Deploy the application to production or release
it to end-users.

Monitoring and Maintenance:

Implement monitoring and logging to track the application's performance and user
interactions. Provide ongoing maintenance, bug fixes, and updates. Monitor user feedback and
address issues promptly.

User Training and Support:

If applicable, provide training to end-users on how to use the application effectively. - Offer
user support and address user inquiries or problems.

Documentation:

Document the application's architecture, codebase, and user manuals. - Maintain up-to-date
documentation for future reference.

Security and Compliance:

Ensure that the application complies with security standards and regulations. - Implement
security measures to protect user data and the system.

Version Control and Collaboration:

Use version control systems (e.g., Git) to manage code versions and collaborate with team
members. - Follow a structured development workflow.

Feedback and Iteration:

Gather feedback from users and stakeholders. - Iterate on the application based on feedback
to improve usability and functionality.

4
Quality Assurance:

Maintain code quality through code reviews and automated testing. - Enforce coding
standards and conduct code inspections.

Release and Distribution:

Release updates and new versions of the application as needed. - Distribute the application
through appropriate channels (e.g., app stores, web deployment).

Post-Release Evaluation:

Evaluate the application's performance and user satisfaction post-release. - Identify areas for
further improvement and prioritize enhancements.

Archiving and Backup:

Maintain archives of code versions, databases, and application configurations. - Implement


regular backups to prevent data loss.

Compliance and Regulations:

Ensure the application complies with legal and regulatory requirements (e.g., data protection
laws).

Retirement or Decommissioning:

Plan for the eventual retirement or decommissioning of the application when it reaches the
end of its lifecycle.

Continuous Learning:

Stay updated with emerging technologies and best practices in application development.

Building an application is an iterative and collaborative process that involves careful planning,
development, testing, and ongoing maintenance. Effective communication with stakeholders and
end-users is crucial throughout the entire lifecycle of the application.

1.3 how does the algorithm work?

An algorithm is a process for doing computations or identifying problems. Algorithms operate as


a precise series of instructions that carry out preset tasks systematically, whether they be software-
based or hardware-based routines. (Anon., 2021)
In all areas of information technology, algorithms are crucial. An algorithm is a simple process
that solves a recurring problem that is frequently used in mathematics and computer science.
Because they set the rules for processing data, algorithms are necessary for automated systems.
An algorithm may be used for simple tasks like sorting lists of numbers or for more challenging
ones like suggesting user content on social media. It is common to provide the initial input and

5
computational instructions for an algorithm. An output is created once the computation is finished.
(Anon., 2021)

1.4 Example of Algorithm for a Simple Calculator:

Step 1. Start

Step 2. Initialize variables:

num1 (for the first number)

num2 (for the second number)

result (for storing the calculation result)

operator (for storing the mathematical operator: +, -, *, /)

Step 3. Display a menu with the available operations:

Addition (+)

Subtraction (-)

Multiplication (*)

Division (/)

Exit (to end the calculator)

Step 4. Prompt the user to select an operation by entering the corresponding operator or "Exit" to
quit.

Step 5. If the user selects "Exit," end the program.

Step 6. If the user selects an operation, do the following:

Prompt the user to enter the first number (num1).

Prompt the user to enter the second number (num2).

Based on the selected operator, perform the corresponding calculation:

For addition, set the result to num1 + num2.

For subtraction, set result to num1 - num2.

For multiplication, set result to num1 * num2.

For division, check if num2 is not zero, then set result to num1 / num2. If num2 is zero, display an
error message (division by zero).
6
Display the result of the calculation.

Step 7. Repeat steps 3 to 6 until the user chooses to exit.

Step 8. End

This algorithm outlines the basic steps for creating a simple calculator application. I would need to
implement this algorithm in my chosen programming language, taking care of input validation and
error handling along the way.
1.5 Determine the steps taken from writing code to execution

The steps from writing code to the execution of a program based on the provided algorithm are as
follows:

Writing Code:

Develop the program logic and functionality in a programming language of choice (e.g., Java,
Python).

Translate the algorithm into actual code.

Code Compilation/Interpretation:

Compile the code (for compiled languages like Java) or interpret it (for interpreted languages like
Python) to create an executable program.

Execution:

Run the compiled/interpreted program. This can be done through a command line or an integrated
development environment (IDE).

Initialization of Variables:

At the start of the program, the variables num1, num2, result, and operator are initialized.

Display Menu:

The program displays a menu to the user, listing available operations (addition, subtraction,
multiplication, division, and exit).

User Interaction:

The user interacts with the program by selecting an operation from the menu or choosing to exit.

User Input:

If the user selects an operation, the program prompts the user to input two numbers (num1 and
num2).

Calculation:

7
Based on the selected operator, the program performs the corresponding calculation:

For addition, it sets result to num1 + num2.

For subtraction, it sets result to num1 - num2.

For multiplication, it sets result to num1 * num2.

For division, it checks if num2 is not zero and sets result to num1 / num2. If num2 is zero, it displays
an error message for division by zero.

Display Result:

The program displays the result of the calculation to the user.

Loop:

The program repeats steps 5 to 9 until the user chooses to exit.

Program Termination:

When the user selects "Exit," the program terminates, and control returns to the operating system.

Testing and Debugging:

During the development and execution process, the program should be thoroughly tested with
different inputs to ensure it functions correctly.

Debugging tools and techniques can be used to identify and fix any issues.

Documentation:

Document the code with comments and provide any necessary user instructions or documentation.

Deployment (if applicable):

If the program is intended for distribution, it can be deployed to the target environment or users.

User Training and Support (if applicable):

Provide training or support to end-users if the program is deployed in a real-world scenario.

Maintenance and Updates (if applicable):

Periodically update the program to address issues, add new features, or improve performance.

Version Control and Collaboration (if working in a team):

Use version control systems (e.g., Git) to manage code versions and collaborate with team members.

Monitoring and Logging (for production applications):


8
Implement monitoring and logging to track the program's performance and user interactions.

Security and Compliance (if applicable):

Ensure that the program complies with security standards and regulations.

Feedback and Iteration:

Gather user feedback and make iterative improvements to the program based on user needs and
issues encountered.

Retrospective (for development teams):

Conduct retrospectives to review the development process and identify areas for improvement.

Archiving:

Maintain archives of code versions and documentation for future reference and auditing.

These steps may vary depending on the specific programming language, development environment,
and project requirements. It's essential to follow best practices in software development to create a
reliable and maintainable application.

1.6 Analyses the process of writing code

Analyzing the process of writing code for the provided algorithm (a simple calculator) and
potential challenges:

Initialization of Variables:

You need to declare and initialize variables like num1, num2, result, and operator to store user input
and calculation results.

Displaying a Menu:

Displaying a menu with available operations is straightforward using System.out.println().

User Input and Operator Selection:

You'll need to use Scanner or a similar mechanism to get user input for operator selection and the
two numbers.

Performing Calculations:

Based on the selected operator, perform the calculation and store the result in the result variable.

Error Handling for Division by Zero:

When division is chosen, check if num2 is zero to avoid division by zero errors. Handle this case
gracefully by displaying an error message.
9
Displaying the Result:

Print the result of the calculation using System.out.println().

Loop for Repeated Calculations:

Use a loop (e.g., while or do-while) to allow the user to perform multiple calculations without
restarting the program.

Exiting the Calculator:

Provide an option for the user to exit the calculator. You can use a loop control variable or the break
statement to exit the loop and end the program.

User Input Validation: Ensuring that user inputs are valid (e.g., numeric values for numbers, valid
operator selection) can be challenging. You may need to implement input validation and handle
exceptions.

Error Handling: Handling errors gracefully, especially division by zero, is important for a robust
calculator.

User Experience: Designing a user-friendly and intuitive menu and input process is crucial.

Testing: Thoroughly testing the calculator to ensure it works correctly for various inputs and edge
cases.

1.7 Process of writing code Calculator


import java.util.Scanner;
public class SimpleCalculator {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double num1, num2, result;
char operator;
while (true) {
// Display the menu
System.out.println("Calculator Menu:");
System.out.println("1. Addition (+)");
System.out.println("2. Subtraction (-)");
System.out.println("3. Multiplication (*)");
System.out.println("4. Division (/)");
System.out.println("5. Exit");

System.out.print("Enter your choice: ");


int choice = scanner.nextInt();

if (choice == 5) {
System.out.println("Exiting the calculator.");
break;
}

System.out.print("Enter the first number: ");


10
num1 = scanner.nextDouble();
System.out.print("Enter the second number: ");
num2 = scanner.nextDouble();

switch (choice) {
case 1:
operator = '+';
result = num1 + num2;
break;
case 2:
operator = '-';
result = num1 - num2;
break;
case 3:
operator = '*';
result = num1 * num2;
break;
case 4:
operator = '/';
if (num2 != 0) {
result = num1 / num2;
} else {
System.out.println("Error: Division by zero.");
continue;
}
break;
default:
System.out.println("Invalid choice. Please try again.");
continue;
}

System.out.println("Result: " + num1 + " " + operator + " " + num2 + " = " + result);
}

scanner.close();
}
}

1.8 relationship between the written algorithm and the code variant.

The Java code provided is an implementation of the algorithm for a simple calculator that you
outlined earlier. Let's evaluate the code and its relationship with the algorithm:

Initialization of Variables: In the code, you've declared and initialized variables num1, num2,
result, and operator to store user input and calculation results. This corresponds to the algorithm's
step of initializing variables.

Displaying a Menu: The code displays a menu with available operations using System.out.println(),
aligning with the algorithm's menu display.

11
User Input and Operator Selection: The code uses a Scanner to get user input for operator
selection and the two numbers, in line with the algorithm's prompt for user input.

Performing Calculations: Based on the selected operator, the code performs the calculation and
stores the result in the result variable. This matches the algorithm's calculation logic.

Error Handling for Division by Zero: The code checks if num2 is zero when division is chosen
and displays an error message if necessary, exactly as specified in the algorithm.

Displaying the Result: After performing the calculation, the code displays the result of the
calculation using System.out.println(). This corresponds to the algorithm's result display.

Loop for Repeated Calculations: The code uses a while loop to allow the user to perform multiple
calculations without restarting the program, just like the algorithm's repetition of steps.

Exiting the Calculator: The code provides an option for the user to exit the calculator using the
"Exit" menu item and the break statement to exit the loop, aligning with the algorithm's exit
condition.

The code closely follows the algorithm's steps and logic, making it a faithful implementation of the
provided algorithm for a simple calculator in Java. It demonstrates the relationship between the
written algorithm and the corresponding code variant, showing how the algorithm's logic is
translated into executable code.

12
References
Anon., 2018. Auxiliary View Its Types, Methods. [Online]
Available at: https://civilseek.com
[Accessed 01 March 2022].
Anon., 2021. studocu. [Online]
Available at: https://www.studocu.com/row/document/esoft-metro-campus/hnd-in-computing/p1-
pragramming-asessment-short-note/30499955
[Accessed 2022].
Anon., 2022. https://ccea.org.uk/downloads/docs/Support/AS%201%20Support/2019/Section%20D%3A
%20Fact%20Files%20-%20Design%20and%20Communication.pdf. [Online]
Available at: https://ccea.org.uk/downloads/docs/Support/AS%201%20Support/2019/Section%20D%3A
%20Fact%20Files%20-%20Design%20and%20Communication.pdf
Anon., 2022. https://doncorgi.com/blog/orthographic-drawing-examples/. [Online]
Available at: https://doncorgi.com/blog/orthographic-drawing-examples/
Anon., 2022. https://everythingwhat.com/what-are-pictorial-techniques. [Online]
Available at: https://everythingwhat.com/what-are-pictorial-techniques
Anon., 2022. https://studylib.net/doc/25296663/benefits-and-limitations-of-different-drawing-styles--1-.
[Online]
Available at: https://studylib.net/doc/25296663/benefits-and-limitations-of-different-drawing-styles--1-
Anon., 2022. https://www.civilclick.com/isometric-projection/. [Online]
Available at: https://www.civilclick.com/isometric-projection/
Anon., 2022. https://www.civilclick.com/isometric-projection/. [Online]
Available at: https://www.civilclick.com/isometric-projection/
Anon., 2022. https://www.tasstudent.com/pictorial-drawing/#:~:text=It%20is%20a%20method
%20of,traditional%20drawing%20equipment%20is%20needed. [Online].
Anon., 2022. https://www.tasstudent.com/pictorial-drawing/#:~:text=It%20is%20a%20method
%20of,traditional%20drawing%20equipment%20is%20needed. [Online]
Available at: https://www.tasstudent.com/pictorial-drawing/
Anon., n.d. Auxiliary Views. [Online]
Available at: https://cabarrus.k12.nc.us
[Accessed 01 March 2022].
Branoff, T. J., 2016. Interpreting Engineering Drawings. 8th ed. Australia: Cengage Drawing.
Tooley, M. & Dingle, L., 2002. BTEC NATIONAL ENGINEERING. 1st edition ed. Great britain: Newnes.
13
14

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy