Please use Pseudocode Project in a nutshed: Determine the of a set of numbers af
ID: 3583744 • Letter: P
Question
Please use Pseudocode
Explanation / Answer
Mainline : coordiantes the activities of the subtasks .
basically , what this means is we are looking to create a module , which will hold the records of all games ( denoted as subtasks ) in multiple arrays ( arrayname will denote the game's name which will hold the all scores)
Get Scores : this module will, allow the user to input scores one at a time , of a particular game at one time. this will then send this score array to the mainline function for maintaince .
Find min/nax : this will take the score array of a particular game as a parameter, and return the min or max scores for that game.
Calculate Truncated Mean : this module, will basically calculated a trimmed mean of the scores of a particular game. here , we need to subtract the largest and the smallest scores taken in as a parameter and then calculate the mean, which will be our truncated mean.
Report : this module will simply output the scores of a particulaar game, along with the mean. The array for the scores of that game will be taken in as a parameter.
-----------------------------------------------
to calculate min of an array , we will do the following ,
1. initialize a min variable to a very large number ( such that all possible scores are lesser than it )
2. traverse the score array and compare min to array[i]
if min > array [i] let min = array[i]
3. do this for all array elements.
final value of min is the smallest element in the array.
for MAX :
1. initialize a max variable with a very small number ( such that all possible scores are greater than it )
2. traverse the score array and compare max to array[i]
if max < array [i] let max = array[i]
3. do this for all array elements.
final value of max is the greatest element in the array.
---------------------------------------------------------------
to calculate the truncated mean
1. calculate the sum of all scores in that array.
2. subtract the smallest and largest element from this sum.
3. divide by the number of scores to get the final mean.
------------------------------------------------------------------------------------------------
psuedo code ---
-----------------------------------------------------------------------------------------------
get_score()
{
declare array[]
i=0
input=1
while(input)
{
array[i] = input score
i++
print("do you wish to continue 1 or 0" )
scan(input) //if input is 1 we take more user values , if 0 we quit
}
return array
}
mainline ()
{
print("select the game for which you must enter scores " )
//print all games whose score arrays are declared as game[] (example int basketball[] etc )
game = get_scores() // this "game" is based on what the user selected above, use switch case, or basic if else for this.
}
find_min( array )
{
size = len(array)
min = infinity (large number like 10000000000000)
while(size--)
{
if(min> array[i])
{ min=array[i]
}
}
return min;
}
find_max( array )
{
size = len(array)
max = -infinity (small number like -10000000000000)
while(size--)
{
if(max < array[i])
{ max=array[i]
}
}
return max;
}
truncated_mean(array , smallest, latgest)
{
double sum = 0;
size = len(array)
while(size--)
{
sum = sum + array[size]
}
sum = sum - smallest - largest
return sum/size //mean = sum of all values/number of values
}
report ( array , mean )
{
size = len(array)
i=0
while( i < size)
{
print " scores are "
print array[i]
i++
}
print " the mean is "
print mean
}
-------------------------------------------------------------------
driver program for these modules
-------------------------------------------------
main()
{
print " select your game to input "
mainline() //calls get scores internally
print " to find max of which game"
scan(array) ///user enters the game
int max = fin_max(array)
//similarly for min
int min = find_min(array)
//to calculate mean
double output = truncated_mean(array , min, max)
//to output
report(array, mean)
}