Code can be presented much more readable using CODE tags:
public static void main (String[] args) throws java.lang.Exception
{
Scanner s = new Scanner(System.in);
int cases = s.nextInt();
for (int i = 0; i < cases; i++) {
int n = s.nextInt();
double val =1.0;
for (int j = 1; j < 9; j++) {
val = val* (n+j);
}
double result = ((n+9.0)/9.0-(40320.0/val));
System.out.printf("%.6f\n", result);
}
}
I don't know how big the performance difference is in java, but generally it is much more preferable to do as much as possible of any calculation using int data types (mostly because of accuracy issues). Does your "val" variable need to be a float type?
In this problem, there's another possible optimization. Analyze the results of your code medium to large "n" values.