Explore BrainMass
Share

# Program Test Procedures

Generate a set of test inputs and expected results for the Currency Conversion program.

Pseudocode:

Input: Arrays of Employee Name and Salary [1..N]
Output: MeanSalary, nSalaryAbove, nSalaryBelow
Uses: BubbleSort

Declaration:
Real TotalSalary, MeanSalary
Integer nSalaryAbove, nSalaryBelow, Count, i

Process Begin
//sort the Salary Array
Call BubbleSort(Salary[1..N])

//Find the Average
TotalSalary = 0
Count = 0
For i = 1 to N
Do
TotalSalary = TotalSalary + Salary[i]
Count = Count + 1
Done

MeanSalary = TotalSalary / Count

//Find the number of salaries above or below the mean
nSalaryAbove = 0
nSalaryBelow = 0
For i = 1 to N
Do
If Salary[i] > MeanSalary
Then
nSalaryAbove = nSalaryAbove + 1
Else If Salary[i] < MeanSalary
Then
nSalaryBelow = nSalaryBelow + 1
End if

Done

//Output
Print "The Average Salary is ", MeanSalary
Print "The number of salaries above the Mean is ", nSalaryAbove
Print "The number of salaries below the Mean is ", nSalarBelow

Process End

Sub BubbleSort //Sorts the array in Ascending/Non-Decreasing Order
Input Array[1..N]
Output Sorted Array[1..N]

Declaration:
Integer Sorted //It's a flag to check if the Array is sorted
Integer k, i
Process Begin
//check if already sorted

Do //Begin the Sorting Loop
Sorted = True //Assume it is Sorted
For i = 1 to N-1
Do
If Array[i] > Array[i+1]
Then
Sorted = False
ExitLoop //Breaks out of this loop
End if
Done
If Sorted = True //The Array is already sorted, so End the Program
Then
End Sub
Else //Array needs to be sorted

//Go through the array once and swap the
For k = 1 to N-1
Do
If Array[k] > Array[k+1]
Then //Swap Array[i] with Array[i+1]
Temp = Array[i]
Array[i] = Array[i+1]
Array[i+1] = Temp
End if
Done

While True //End Do
Process End

© BrainMass Inc. brainmass.com June 22, 2018, 7:37 am ad1c9bdddf

#### Solution Summary

This solution provides the learner with a set of procedures to be utilized for a computer currency conversion program.

\$2.19