Pages

1/19/2014

UVA 10195 Solution

import java.util.Scanner;


class Main {

/**UVA java solution to  10195
* @param args
*/
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);

double[]  side = new double[3];
while(sc.hasNext()) {
for (int i =0; i<3 ;i++) {
side[i] = sc.nextDouble();
}

double d = 0.5 *  (side[0] + side[1] + side [2]);
if(d!=0) {
double area =  Math.sqrt(d* (d-side[0]) * (d-side[1]) * (d-side[2]));
double rad = area / d;
System.out.printf("The radius of the round table is: %.3f\n", rad);
}
else
//if (rad == Nan) System.out.println();;
System.out.printf("The radius of the round table is: 0.000\n");
}
}

}

No comments :

Post a Comment