Saturday, March 26, 2016

URI Solution 1006 in C, C++ and Java language (URI online Judge)

Read three values (variables A, B and C), which are the three student's grades. Then, calculate the average, considering that grade A has weight 2, grade B has weight 3 and the grade C has weight 5. Consider that each grade can go from 0 to 10.0, always with one decimal place.

Input

The input file contains 3 values of floating points with one digit after the decimal point.

Output

Print MEDIA(average in Portuguese) according to the following example, with a blank space before and after the equal signal.
Input SamplesOutput Samples
5.0
6.0
7.0
MEDIA = 6.3
5.0
10.0
10.0
MEDIA = 9.0
10.0
10.0
5.0
MEDIA = 7.5



Solution in C language:



#include <stdio.h>
int main()
{
double a, b, c, media;
scanf("%lf%lf%lf", &a, &b, &c);
media = (a/10 * 2) + (b/10 * 3) + (c/10 * 5);
printf("MEDIA = %.1lf\n", media);
return 0;
}





Solution in C++ language:



#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double a, b, c, media;
cin >> a >> b >> c;
media = (a/10 * 2) + (b/10 * 3) + (c/10 * 5);
cout << "MEDIA = "<< fixed << setprecision(1) << media << endl;
return 0;
}

Solution in Java language:


package uri_java_problem_solution;
import java.util.Scanner; public class URI_1006 { public static void main(String[] args){ double a, b, c, med; Scanner sc =new Scanner(System.in); a =sc.nextDouble(); b =sc.nextDouble(); c =sc.nextDouble(); med = (a/10 * 2) + (b/10 * 3) + (c/10 * 5); String media = String.format("MEDIA = %,.1f", med); System.out.print(media +"\n"); } }

2 comments:
Write comments
  1. For this problem, you’ll have to implement the DFS algorithm. Your input will be the
    adjacency matrix of an undirected, unweighted graph where all the nodes will be integer
    numbers (Node numbers will be 0, 1, 2, 3, …..). But you must have to follow the rule given
    below:
    “If you’ve to push more than one node into the stack, push the nodes in descending
    order. For example, if you need to push node 6, 4 & 5 into the stack, push 6, 5 & 4
    (in this order).

    plzzz solve 10 mints

    ReplyDelete

To know more about the problem, give us your valuable commment. We'll try to help you. Thanks

All rights reserved ©2016 -URI ONLINE JUDGE SOLUTION | Developed by Maniruzzaman Akash

© 2016 URI ONLINE JUDGE SOLUTION. Developed by Maniruzzaman Akash | Distributed By Gooyaabi Templates
Powered by Blogger.