$24
1. Problem Statement
Create a program that reviews arrays and provides practice in compiling and running program in Windows and Linux.
2. Requirements
2.1 Assumptions
User will enter positive integers
Array will only contain positive integers
Array will contain 6 positive integers
Array will be formatted in a 3x2 fashion
Command line input/output only
2.2 Specifications
Program will initialize 2 dimensional array with below data
Rows 3
Columns 2
{ {3,2} {4,5} {2,2} }
Immediately print formatted array with EVEN positive integers identified
User must then enter new values to fill the array
For valid positive integer
Insert integer into user defined array
For invalid input
Alert user and prompt for new input
Print formatted user array with EVEN positive integers identified
Loop filling array with new values until user wishes to terminate program.
Decomposition Diagram
2 Dimensional Array Testing Program
Input
User inputs positive integers by command line
User inputs if they would like to continue or not
Validate user input before inserting it
Process
Iterating through array to insert values
Iterating through array to check if values are EVEN
Output
Format and print array of positive integers
Alert user if input is invalid
Ask if user would like to continue or not
Test Strategy
Valid Data
Invalid Data
Test Plan Windows Version
***All test cases appear the same in table for Linux, validated with screenshots.
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Positive Integers Array
1 … 6
Integer Inserted
{1,2},{3,4},{5,6}
Pass
Valid Data
2
Valid Choice
y
Enter Again
Valid Data
3
Valid Choice
N
Exit Program
Invalid Data
1
Negative Integer Array
-1
Prompt to retry
Initial Algorithm
Define Global Constants
Max Rows of 3
Max Columns of 2
Create Function howManyEven
Parameters and Returns
Parameter: 2 Dimensional Array arrayIntValues
Return integer of how many even integers are contained in array
Iterate through first portion of array
If integer read is even
Iterate counter to be returned
If integer read is odd
Continue reading
Create Function printArray
Parameters and Returns
Parameter: 2 Dimensional Array arrayIntValues
Return void
Iterate through first portion of array
Print formatted row
Print formatted column
MAIN FUNCTION
Create and Initialize 2 Dimensional array arrayIntValues
{ {3,2} {4,5} {2,2} }
Create 2 holder variables
One integer to hold integer input
One char to determine continue/exit
Use printArrayto show default array to user
Use howManyEvento show the user how many even integers there are
Do until user enters ‘n’ to stop program
Alert user: “All future non-integer inputs will be rounded down.”
Prompt user to enter new integers into the command line
If input is valid
Insert input into array
If input is invalid
Alert user and attempt again
Use printArrayto display new user generated array
Use howManyEvento display number of user generated even integers
Prompt user: “Would you like to insert more positive integers?”