Computer Science Homework Solutions
Problem
#189967

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


Solution Summary

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

Solution
What is this?
By OTA - Overall OTA Rating
Purchase Cost Now
$2.19 CAD (was ~$11.97)
Included in Download
  • Plain text response
  • Attached file(s):
    • Test+Input.doc
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Examples of correct Variable declaration in C++ - Which of the following variable declarations are correct? If a variable declaration is not correct give the reason(s) and provide the correct variable declaration. n = 12; //Line 1 ...
  • Data Structures C++ - Consider the following statement: class strange { . . . }; a. Write a statement that shows the declaration in the class strange to overload the operator >>. b. Write a statement that shows ...
  • HELP WITH THESE THREE QUESTIONS - 1. Why declaration of a variable is considered to be an important (and sometimes required) part of good programming practice? 2. Name few languages that allow use of variables without even declari ...
  • Programming problem - Consider the following Ada skeletal program... - -------------------------------------------------------------------------------- Consider the following Ada skeletal program: procedure Main is X : Interger; procedure Sub3; -- This ...
  • Write a C program that has a declaration in main() to store the string - If you choose to answer problem 2 in Section B, you must complete both parts a and b. a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array nam ...
Browse