1.

/**
 *
 * Problem #11715 - Car
 * http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=117&page=show_problem&problem=2762


 *
 * @author Mariya Vlaseva
 *
 * Methode: Countingsort
 * Status : Accepted
 * Runtime: 0.140
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import java.text.DecimalFormat;
import java.util.Locale;


public class Main {

    /**
     * @param args
     * @throws IOException
     */
    public static void main(String... args) throws IOException {

        BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
        int testCase =1;

        for(String line = console.readLine(); line != null; line = console.readLine()) {
            if(line.trim().equals("")) continue;

            if (line.equals("0")){
                break;
            }       
            String[] splittArray = line.split("\\s+");
            double arg1 = Double.parseDouble(splittArray[1]);

            double arg2 = Double.parseDouble(splittArray[2]);
            double arg3 = Double.parseDouble(splittArray[3]);

            if (splittArray[0].equals("1")){
                calcAS(testCase, arg1, arg2, arg3);

            }
            else if (splittArray[0].equals("2")){
                calcST(testCase, arg1, arg2, arg3);
            }
            else if (splittArray[0].equals("3")){
                calcVT(testCase, arg1, arg2, arg3);

            }
            else {
                calcUT(testCase, arg1, arg2, arg3);
            }
            testCase++;

        }

    }

    private static void calcUT(int count, double v, double a, double s) {

        double u=Math.sqrt(v*v-2*a*s);
        double t=(v-u)/a;
        printResult(count, u, t);
    }

    private static void calcVT(int count, double u, double a, double s) {
        double v=Math.sqrt(u*u+2*a*s);

        double t=(v-u)/a;
        printResult(count, v, t);
    }

    private static void calcST(int count, double u, double v, double a) {
        double t=(v-u)/a;
        double s=(v*v-u*u)/(2*a);

        printResult(count, s, t);
    }

    private static void calcAS(int count, double u, double v, double t) {
        double a=(v-u)/t;
        double s=(v*v-u*u)/(2*a);
        printResult(count, s, a);

    }

    private static void printResult(int testCase, double arg1, double arg2) {
        DecimalFormat format = (DecimalFormat)DecimalFormat.getInstance(Locale.US );
        format.applyPattern( "#,###0.000" );   

        System.out.println("Case " + testCase + ": " + format.format(arg1) + " " + format.format(arg2));
    }
}



2.

/**
* Problem: 11715 Car
* Zeit: 0.092
* Programmiersprache: JAVA
* @author Christoph Miesel
* Status: ACCEPTED
*/


import java.util.*;
import java.io.*;

public class Car
{
public static String r(double d)
{
d *= 1000;
long tmp = Math.round(d);
d = (double)tmp / 1000;
boolean flag = false;
String s = "";

s += d;
int counter = 0;
for(int i = 0; i < s.length(); i++)
{
if(flag)
counter++;
if(s.charAt(i) == '.')
flag = true;
}
for(int i = 0; i < (3 - counter); i++)
s += "0";

return s;
}

public static void main(String[] args)throws IOException
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line = reader.readLine();

long tmp;
double u,v,a,t,s;
int c,counter; //case
StringTokenizer token = new StringTokenizer(line);
counter = 0;
while(true)
{
c = Integer.parseInt(token.nextToken());
if(c == 0)
break;
switch(c)
{
case 1:
u = Double.parseDouble(token.nextToken());
v = Double.parseDouble(token.nextToken());
t = Double.parseDouble(token.nextToken());
s = u*t+0.5*(v-u)*t;
a = (v-u)/t;
++counter;

System.out.println("Case "+counter+": "+r(s)+" "+r(a));
break;
case 2:
u = Double.parseDouble(token.nextToken());
v = Double.parseDouble(token.nextToken());
a = Double.parseDouble(token.nextToken());
t = (v - u)/a;
s = u*t + 0.5*a*t*t;
++counter;
System.out.println("Case "+counter+": "+r(s)+" "+r(t));
break;
case 3:
u = Double.parseDouble(token.nextToken());
a = Double.parseDouble(token.nextToken());
s = Double.parseDouble(token.nextToken());
t = -u/a + Math.sqrt(u*u + 2*a*s)/a;
if(-u/a - Math.sqrt(u*u + 2*a*s)/a > t)
t = -u/a - Math.sqrt(u*u + 2*a*s)/a;
v = a*t + u;
++counter;
System.out.println("Case "+counter+": "+r(v)+" "+r(t));
break;
case 4:
v = Double.parseDouble(token.nextToken());
a = Double.parseDouble(token.nextToken());
s = Double.parseDouble(token.nextToken());
u = Math.sqrt(v*v - 2*a*s);
t = s/(u+0.5*(v-u));
++counter;
System.out.println("Case "+counter+": "+r(u)+" "+r(t));
break;
}
line = reader.readLine();
token = new StringTokenizer(line);
}
}
}