Click
Here to go back to the homepage.
Dice Game Solution:
import java.util.Scanner;
import java.util.stream.IntStream;
public class Kattis {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = sc.nextInt();
double idk = IntStream.rangeClosed(a, b).sum() / (double) (b-a+1) + IntStream.rangeClosed(c, d).sum() / (double) (d-c+1);
int e = sc.nextInt();
int f = sc.nextInt();
int g = sc.nextInt();
int h = sc.nextInt();
double idk2 = IntStream.rangeClosed(e, f).sum() / (double) (f-e+1) + IntStream.rangeClosed(g, h).sum() / (double) (h-g+1);
if(idk > idk2){
System.out.println("Gunnar");
}
else if(idk2 > idk){
System.out.println("Emma");
}
else{
System.out.println("Tie");
}
}
}