# URI / BEE CROWD 1079 - Weighted Averages Solution in C,C++,Python | URI - BEECROWD - BEE 1079 Solution in C,C++,Python

beecrowd | 1079

# Adapted by Neilor Tonin, URI  Brazil

Timelimit: 1

Read an integer N, which represents the number of following test cases. Each test case consists of three floating-point numbers, each one with one digit after the decimal point. Print the weighted average for each of these sets of three numbers, considering that the first number has weight 2, the second number has weight 3 and the third number has weight 5.

## Input

The input file contains an integer number N in the first line. Each following line is a test case with three float-point numbers, each one with one digit after the decimal point.

## Output

For each test case, print the weighted average according with below example.

 Input Sample Output Sample 36.5 4.3 6.25.1 4.2 8.18.0 9.0 10.0 5.76.39.3

### Demonstration:

To find a weighted average, multiply each number by its weight, then add the results. If the weights don't add up to one, find the sum of all the variables multiplied by their weight, then divide by the sum of the weights.
The weights do not have any physical units and are only numbers expressed in percentages, decimals, or integers. The weighted average formula is the summation of the product of weights and quantities, divided by the summation of weights.
Weighted Average (Weights×Quantities) / Weights
N.B: Don't copy paste the code as same. Just try to understand it and try yourself.

## URI / BEECROWD Online Judge 1079 Solve in C :

```#include<stdio.h>

int main()
{
int n,i;
float a,b,c,sum,avg;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%f %f %f",&a,&b,&c);
sum=a*2+b*3+c*5;
avg=sum/(2+3+5);
printf("%.1f\n",avg);
}

return 0;
}```