$24
1. Problem Statement
Given a struct clientData, build a program that can fill a file with instances of this data and read it back.
2. Requirements
2.1 Assumptions
Some of the code is provided on the “instruction” sheet.
Command Line Input Only
User will only enter integers where applicable
User will only enter doubles where applicable
2.2 Specifications
Struct clientData will be used
File will be accessed randomly
File will accommodate 100 user inputs
User can request specific accounts
Program will print out all used accounts in order
Decomposition Diagram
Program
Input
Integer Account Number
Character Array First Name
Character Array Last Name
Double Account Balance
Process
Create Default File
Push Respective Data to Output Stream
Output
Output Default File
Push Output Stream to File
Print Data to Console
Test Strategy
Valid Data
● Invalid Data
Test Plan Version 1
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
File Exists
Valid Data
2
Set Account #
Valid Data
3
Set Account #
Valid Data
4
Set Account First
Name
Valid Data
5
Set Account Last
Name
Valid Data
6
Set Balance
Valid Data
7
Set Balance
Invalid Data
1
Set Account #
Invalid Data
2
Set Account #
Invalid Data
3
Set First Name
Too Large
Invalid Data
4
Set Last Name
Too Large
Invalid Data
5
Set Balance
Negative
Invalid Data
6
Asking for unused
account
Initial Algorithm
Create Struct clientData
Integer accountNumber
Character Array lastName[15]
Character Array firstName[10]
Float balance
Create Function createBlankFile
Parameters: clientData blankClient
Return: Void
Method:
Open Output Stream
Name File “client.dat”
Iterate 100 Times
Fill with blankClient
Close Output Stream
Create Function writeToFile
Parameters: clientData client
Return: Void
Method:
Open Output Stream
Do While Account Number is not 0
Prompt for initial Account Number
IF 0
Exit Function
Else IF 1 = Account Number = 100
Fill First Name
Fill Last Name
Fill Balance
Seek Position of Account Number in file
Write client data to file
Else
Alert Invalid Account Number
Create Function userRead
Parameters: clientData client
Return: Void
Method:
Create Input Stream
Do While
Prompt for Account Number
IF input = 0
Return/Exit
Else IF 1 <= input <= 100
Seek Input
Read Input
IF Input != 0
Output Data
Else
Alert Invalid Account Number
Create Function printAllRecords
Parameters: clientData client
Return: Void
Method:
Create Input Stream
Read Initial Data
While inCredit && !inCredit @ End Of File
IF client.accountNumber != 0 a. Output Data
Read Next Data
Create MAIN
Create and Initialize client and blankClient as {0,””,””,0.0}
Perform createBlankFile(blankClient)
Perform writeToFile(client)
Perform userRead(client)
Perform printAllRecords(client)
Return 0;
Test Plan Version 2
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
File Exists
createBlankFile
File Output
Correct
Valid Data
2
Set Account #
1
Account #1
Valid Data
3
Set Account #
100
Account #100
Valid Data
4
Set Account First
Bill
First Name: Bill
Name
Valid Data
5
Set Account Last
Gates
Last Name: Bill
Name
Valid Data
6
Set Balance
1234.56
Balance: 1234.56
Valid Data
7
Set Balance
1
Balance: 1
Invalid Data
1
Set Account #
-1
Out of Range
Invalid Data
2
Set Account #
101
Out of Range
Invalid Data
3
Set First Name
abcdefghijk
First Name
Too Large
Corrupted
Invalid Data
4
Set Last Name
abcdefghijklmno
Last Name
Too Large
p
Corrupted
Invalid Data
5
Set Balance
-100
Try Again
Negative
Invalid Data
6
Asking for unused
1 when unused
Account Not In
account
Use
9. Updated Algorithm
1. Create Struct clientData
a. Integer accountNumber
b. Character Array lastName[15]
c. Character Array firstName[10]
d. Float balance
Create Function createBlankFile
Parameters: clientData blankClient
Return: Void
Method:
Open Output Stream
Name File “client.dat”
Iterate 100 Times
Fill with blankClient
Close Output Stream
Create Function writeToFile
Parameters: clientData client
Return: Void
Method:
Open Output Stream
Do While Account Number is not 0
Prompt for initial Account Number
IF 0
Exit Function
Else IF 1 = Account Number = 100
Fill First Name
Fill Last Name
Fill Balance
Seek Position of Account Number in file
Write client data to file
Else
Alert Invalid Account Number
Create Function userRead
Parameters: clientData client
Return: Void
Method:
Create Input Stream
Do While
Prompt for Account Number
IF input = 0
Return/Exit
Else IF 1 <= input <= 100
Seek Input
Read Input
IF Input != 0
Output Data
Else
Alert Invalid Account Number
accountNumber = -1
Else
Alert Account Number Out Of Range
accountNumber = -1
Create Function printAllRecords
Parameters: clientData client
Return: Void
Method:
Create Input Stream
Read Initial Data
While inCredit && !inCredit @ End Of File
IF client.accountNumber != 0
Output Data
Output Account Number
Output First Name
Output Last Name
Output Balance
Read Next Data
Create MAIN
Create and Initialize client and blankClient as {0,””,””,0.0}
Perform createBlankFile(blankClient)
Perform writeToFile(client)
Perform userRead(client)
Perform printAllRecords(client)
Return 0;
Test Plan Version 3
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/
Fail
Valid Data
1
File Exists
createBlankFile
File Output Correct
File Output Correct
Pass
Valid Data
2
Set Account #
1
Account #1
Account #1
Pass
Valid Data
3
Set Account #
100
Account #100
Account #100
Pass
Valid Data
4
Set Account First
Bill
First Name: Bill
First Name: Bill
Pass
Name
Valid Data
5
Set Account Last
Gates
Last Name: Bill
Last Name: Bill
Pass
Name
Valid Data
6
Set Balance
1234.56
Balance: 1234.56
Balance: 1234.56
Pass
Valid Data
7
Set Balance
1
Balance: 1
Balance: 1
Pass
Invalid Data
1
Set Account #
-1
Out of Range
Out of Range
Pass
Invalid Data
2
Set Account #
101
Out of Range
Out of Range
Pass
Invalid Data
3
Set First Name
abcdefghijk
First Name
First Name
Pass
Too Large
Corrupted
Corrupted
Invalid Data
4
Set Last Name
abcdefghijklmn
Last Name
Last Name
Pass
Too Large
op
Corrupted
Corrupted
Invalid Data
5
Set Balance
-100
Try Again
Try Again
Pass
Negative
Invalid Data
6
Asking for unused
1 when unused
Account Not In
Account Not In Use
Pass
account
Use
12. Error Log
Error Type (Logic/Runtime)
Cause of Error
Solution to Error
Logic
Not Resetting
Include resetting to -1 so that
accountNumber while
userIn can be compared
checking for valid input.
correctly.
13. Status
Program is working. Just don’t stress it out too much, it has anxiety.