CS 1101 Programming Assignment Unit 4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

CS 1101 – Programming Fundamentals

University of the People

Programming Assignment Unit 4


Part 1:

To apply incremental development to the task given by the manager, I could do the following

steps:

Initial Setup:

First, defining the basic structure of the function hypotenuse which will take two parameters

representing the lengths of the legs of a right triangle.

Adding Incremental Functionality:

Introducing the calculation of the squares of the two legs within the function.

Completing the Function:

Implementing the final computation of the hypotenuse using the Pythagorean theorem.
At this stage, the function should correctly compute the hypotenuse based on the inputs.

Testing the Function:

Test the function with known values to check for correctness:

Each test checks the function with triangle sides where the hypotenuse is known, verifying if the

function computes the values as expected.

By following these steps, I can methodically develop the function, ensure each component works

as intended before adding more complexity, and effectively minimize potential errors at each

development stage. This process aids in both developing a robust function and in understanding

its operation step-by-step.


Part 2:

As a software developer working on my portfolio, I approached the creation of my custom

function using incremental development, a method emphasized in this week's reading. This

approach involves building the function in, manageable steps, ensuring each part works correctly

before moving on to the next. Here’s how I applied this methodology:

1. Initial Plan and Simple Start:

I started by outlining what my function should do—calculate the Body Mass Index (BMI) based

on height and weight inputs. The simplest version of the function just received the inputs and

printed them out to ensure they were being correctly passed.

Output:
2. Incremental Development:

Next, I incorporated the BMI calculation formula into the function. I tested it with known values

to ensure it calculated correctly.

Output:

3. Enhancing Functionality:

Then, I added functionality to interpret the BMI result according to medical standards (CDC,

n.d.).

Output:
4. Refinement and Documentation:

Finally, I added comments to the code to explain each section and ensure it’s understandable to

others. This helps in maintaining the code and is good practice for professional development.

Using incremental development for the creation of the BMI function allowed for meticulous

validation of each segment of the code. This approach minimized the potential for errors and

simplified debugging, as each part was confirmed to operate correctly before additional

complexity was introduced. Methodically advancing through the stages of development—from

initial input validation to complex logical assessments—helped ensure the function's reliability

and maintainability. The clear documentation accompanying each step further enhanced the

understandability of the code, aiding future revisions or expansions.


Reference

CDC. (n.d.). Assessing Your Weight.

https://www.cdc.gov/healthyweight/assessing/index.html#:~:text=If%20your%20BMI%20is

%20less,falls%20within%20the%20obese%20range

Downey, A. (2015). Think Python: How to think like a computer scientist. Needham,

Massachusetts: Green Tree Press.

You might also like