Starting from:
$30

$24

Lab 0602 Solution




1. Problem Statement




Perform FACTORIAL !




2. Requirements




2.1 Assumptions




User will only input integers



User will only input into the command line



2.2 Specifications




User will input integer to take factorial! of



Program will print factorial!



Decomposition Diagram



Program



Input



User inputs integer



Process



FACTORIAL!



Output



Answer



Test Strategy



Valid Data



Invalid Data



Test Plan Version 1






Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Valid Factorial






















Valid Data
2
Valid Factorial






















Invalid Data
1
Invalid Factorial






















Invalid Data
2
Stack Overflow































Initial Algorithm



Create Function



Name: factorial



Parameters: integer input, bool methodStatus



Return: integer answer



Method:



Set methodStatus to true



If input is less than 0



Set methodStatus to false



Return -1



Else If input equals 0



Return 1



Else



Return Input * factorial(input - 1, methodStatus)



Create Main



Delcare methodStatus as false



Declare integer input as 0



Prompt user for input



Set input



Perform Factorial with input



Test Plan Version 2






Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Valid Factorial
5
120


















Valid Data
2
Valid Factorial
0
1


















Invalid Data
1
Invalid Factorial
-1
-1


















Invalid Data
2
Stack Overflow


Stack Overflow
























9. Updated Algorithm




Create Function



Name: factorial



Parameters: integer input, bool methodStatus
Return: integer answer



Method:



Set methodStatus to true



If input is less than 0



Set methodStatus to false



Return -1



Else If input equals 0



Return 1



Else



Return Input * factorial(input - 1, methodStatus)



Create Main



Delcare methodStatus as false



Declare integer input as 0



Prompt user for input



Set input



Perform Factorial with input









Test Plan Version 3






Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Valid Factorial
5
120
120
Pass














Valid Data
2
Valid Factorial
0
1
1
Pass














Invalid Data
1
Invalid Factorial
-1
-1
-1
Pass














Invalid Data
2
Stack Overflow
50000
Stack Overflow
Stack Overflow
Pass























12.
Error Log








Error Type (Logic/Runtime)
Cause of Error
Solution to Error








N/A


N/A
N/A








13.
Status





Broke it as needed. Other than that, success!

More products