版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_38234015/article/details/88316352
import java.util.Scanner;
public class Test2_10 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the amount of water in kilograms: ");
double m = input.nextDouble();
System.out.print("Enter the initial temperature: ");
double inT = input.nextDouble();
System.out.print("Enter the final temperature: ");
double finalT = input.nextDouble();
input.close();
double Q = m * (finalT - inT) * 4184;
System.out.println("The energy needed is " + Q);
}
}