Generate a set of test inputs and expected results


Discussion:

Q: 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

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Generate a set of test inputs and expected results
Reference No:- TGS01931846

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)