In this homework, you will design a program to perform the following task:

*Design and write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.*

There are 4 components of your submission including:

- Program Description- A detailed, clear description of the program you are building.
- Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about how your design will allow any number of students and final grades to be possible inputs.
- Test plan - Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)
- Pseudocode- Provide pseudocode of your overall design that fulfills the requirements of the project

All of these components should be placed in word document for submission.

Example application test data:

Test Case # |
Input |
Expected Output |

1 |
Length =4.0, Width=8.0 |
Area = 32 |

2 |
Your input data |
Your expected output |

3 |
Your input data |
Your expected outp |

**For formatting purposes the whole assignment shoud look like this:**

**Program Description:**

This program will provide options for a user to calculate the square or cube of a positive Integer input by a user. The program will prompt the user to enter an Integer and then prompt the user if they want to calculate the square of the cube of the number. Based on the inputs of the user, the program will output the square of the cube of the positive integer. The program will then print the Integer and square or cube of the integer based on the user’s original choice. The program will continue to prompt the user for Integers and their calculation choice until the user enters a negative integer. The square and cube calculations should be calculated using a function.

**Analysis:**

I will use sequential, selection, and repetition programming statements and functions for the cube and square calculations.

I will define three Integer numbers: IntValue, MenuSelect, Results to store the Integer value input by the user, the Menu selection (1 for Square, 2 for Cube) of the user, and the results of the Square or Cube functions.

The Square function will take one Integer as input and return one Integer as the output. The calculation within the Square function is: Results = IntValue * IntValue

For example, if 10 was entered as the IntValue. Results = 10*10 = 100

The Cube function will take one Integer as input and return one Integer as the output. The calculation within the Cube function is: Results = IntValue * IntValue*IntValue

For example, if 10 was entered as the IntValue. Results = 10*10*10 = 1000

A repetition loop can be used to loop through iterations until a negative is entered:

while(intValue > 0) (

…

End For

** **

** **

** **

** **

** **

**Test Plan:**

To verify this program is working properly the input values could be used for testing:

Test Case |
Input |
Expected Output |

1 |
IntValue=10 |
Square of 10 is 100 |

2 |
IntValue=10 |
Cube of 10 is 1000 |

3 |
intValue=-1 |
Program exits |

**Pseudocode:**

// This program will provide options for a user to calculate the square

// or cube of a positive Integer input by a user.

// Start Main program

Main

// Declare variables

Declare intValue, menuSelect,Results as Integer

// Set intValue to positive value to start loop

Set intVal = 1;

// Loop While input is a positive number

While intValue > 0

Print "Enter a positive Integer to calculate the square or cube; OR a negative Integer to exit the program. "

Input intValue

// Only perform menu and function calls is integer is positive

If intValue > 0 Then

Print "Enter 1 to calculate Square, 2 to Calculate Cube "

Input menuSelect

If menuSelect == 1 Then

// Call the Square Function

Set Results = Square(intValue)

Print intValue,Results

Else If menuSelect == 2 Then

// Call the Cube function

set Results = Cube(intValue)

Print intValue,Results

Else

Print “Invalid menu item, only 1 or 2 is accepted”

End If

End If

END While

// End of Main program

End Program

// Square Function

Function Square(value) as Integer

Set Square = value*value

End Function

// Cube Function

Function Cube(value) as Integer

Set Cube = value*value*value

End Function

Subject | Computer |

Due By (Pacific Time) | 04/05/2015 12:30 pm |

Tutor | Rating |
---|---|

pallavi Chat Now! |
out of 1971 reviews More.. |

amosmm Chat Now! |
out of 766 reviews More.. |

PhyzKyd Chat Now! |
out of 1164 reviews More.. |

rajdeep77 Chat Now! |
out of 721 reviews More.. |

sctys Chat Now! |
out of 1600 reviews More.. |

sharadgreen Chat Now! |
out of 770 reviews More.. |

topnotcher Chat Now! |
out of 766 reviews More.. |

XXXIAO Chat Now! |
out of 680 reviews More.. |