Scanner s = new Scanner(System.in); double g, Q, M = 0, iT, fT, finalTemp, initialTemp; int amountOfWater; System.out.println("Enter the amount of water in gram: "); amountOfWater = s.nextInt(); System.out.println("Enter the initial temperature in Fahrenheit: "); initialTemp = s.nextDouble(); System.out.println("Enter the final temperature in Fahrenheit: "); finalTemp = s.nextDouble(); M =amountOfWater/1000; iT = (initialTemp - 32)/1.8; fT = (finalTemp - 32)/1.8; Q = M *(fT - iT)*4184; System.out.printf("The energy needed is " + Q);