Algorithm


beecrowd | 1005

Average 1

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

 

Read two floating points' values of double precision A and B, corresponding to two student's grades. After this, calculate the student's average, considering that grade A has weight 3.5 and B has weight 7.5. Each grade can be from zero to ten, always with one digit after the decimal point. Don’t forget to print the end of line after the result, otherwise you will receive “Presentation Error”. Don’t forget the space before and after the equal sign.

 

Input

 

The input file contains 2 floating points' values with one digit after the decimal point.

 

Output

 

Print the message "MEDIA"(average in Portuguese) and the student's average according to the following example, with 5 digits after the decimal point and with a blank space before and after the equal signal.

 

 

 

Input Samples Output Samples

5.0
7.1

MEDIA = 6.43182

 

0.0
7.1

MEDIA = 4.84091

 

10.0
10.0

MEDIA = 10.00000

   

 

Main Algorithm to solve URI 1005

(x*3.5+y*7.5) / (3.5+7.5)

 

 

 

Code Examples

#1 URI Online Judge Solution 1005 using C Programming Example

Code - C Programming


#include <stdio.h>
int main(){
    float x,y;
    scanf("%f %f", &x, &y);
    printf("MEDIA = %.5fn", (x*3.5+y*7.5)/(3.5+7.5));
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5.0
7.1

Output

x
+
cmd
MEDIA = 6.43182

#2 URI Online Judge Solution 1005 using C++ Programming Example

Code - C++ Programming


#include <cstdio>

int main()
{
 double a,b,m;

 scanf("%lf %lf", &a, &b);

 m = (a/11 * 3.5) + (b/11 * 7.5);

 printf("MEDIA = %.5lfn", m);

 return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
0.0
7.1

Output

x
+
cmd
MEDIA = 4.84091

#3 URI Online Judge Solution 1005 using Java Programming Example

Code - Java Programming

import java.util.Scanner;
public class URI_1005 {
    public static void main(String[] args){

  float a, b, m;
  Scanner sc = new Scanner(System.in);
  a = sc.nextFloat();
  b = sc.nextFloat();

  m = (float) ((a/11 * 3.5) + (b/11 * 7.5));

  System.out.printf("MEDIA = %.5fn", m);
  }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
10.0
10.0

Output

x
+
cmd
MEDIA = 10.00000

#4 URI Online Judge Solution 1005 using Python Programming Example

Code - Python Programming


nota1 = float(input())
nota2 = float(input())

media = (((nota1 * 3.5) + (nota2 * 7.5)) / 11)

print("MEDIA = %0.5f" %media)
Copy The Code & Try With Live Editor

Input

x
+
cmd
10.0
10.0

Output

x
+
cmd
MEDIA = 10.00000

#5 URI Online Judge Solution 1005 using C# Programming Example

Code - C++ Programming


using System;
class URI {
 
    static void Main(string[] args) {

            double a, b;
            a = Convert.ToDouble(Console.ReadLine());
            b=Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("MEDIA = " + ((a*3.5 + b*7.5)/(3.5+7.5)).ToString("0.00000"));
            Console.ReadKey();

    }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5.0
7.1

Output

x
+
cmd
MEDIA = 6.43182
Advertisements

Demonstration


URI Online Judge Solution 1005 Average 1 – Solution in C, C++, Java, Python and C#

Previous
#1004 Beecrowd Online Judge Solution 1004 in C, C#, Java, Python easily
Next
#1006 Beecrowd Online Judge Solution 1006 Average 2 - Solution in C, C++, Java, Python and C#