You will use sequential, selection and repetition programming statements. You will define one integer number: count count will store how many times valid weights and values have been entered. You will define a variety of doubles: weight, value, sum, sumw, avg value will store the input value weight will store the input weight for that value sum will store the running sum of values and weights sumw will store the running of the weights avg will store the weighted average of the 5 numbers and 5 weights input. The running sum will be calculated by this formula: sum = sum + value * weight For example, if the first value and weight pair entered is 4, 1 and second pair is 10, 3: sum = sum + value*weight = 0 + 4*1 sum = 4 + 10*3 = 34 sumw = 1 + 3 = 4 Values and sum are to be input and calculated within a repetition loop: while count < 5 Input value, weight sumw = sumw + weight sum = sum + value * weight count = count + 1 End while Avg is calculated by: avg = sum / sumw You will use sequential, selection and repetition programming statements. You will define one integer number
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
You will use sequential, selection and repetition
You will define one integer number: count
count will store how many times valid weights and values have been entered.
You will define a variety of doubles: weight, value, sum, sumw, avg value will store the input value
weight will store the input weight for that value
sum will store the running sum of values and weights sumw will store the running of the weights
avg will store the weighted average of the 5 numbers and 5 weights input.
The running sum will be calculated by this formula: sum = sum + value * weight
For example, if the first value and weight pair entered is 4, 1 and second pair is 10, 3: sum = sum + value*weight = 0 + 4*1
sum = 4 + 10*3 = 34 sumw = 1 + 3 = 4
Values and sum are to be input and calculated within a repetition loop:
while count < 5 Input value, weight
sumw = sumw + weight
sum = sum + value * weight
count = count + 1
End while
Avg is calculated by:
avg = sum / sumw
You will use sequential, selection and repetition programming statements.
You will define one integer number
Below I will provide the code in python
Step by step
Solved in 3 steps with 1 images