forked from HarryDulaney/intro-to-java-programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExercise02_10.java
39 lines (22 loc) · 976 Bytes
/
Exercise02_10.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package Ch_2;
import java.util.Scanner;
//Heats what from an initial temperature to a final temperature
public class Exercise02_10 {
public static void main(String[]args) {
double initialTemperature;
double finalTemperature;
double weightofwater;
System.out.println("Enter the weight of the water in Kilograms");
Scanner input = new Scanner(System.in);
weightofwater = input.nextDouble();
System.out.println("Enter the initial temperature of the water in Celsius");
Scanner input1 = new Scanner(System.in);
initialTemperature = input1.nextDouble();
System.out.println("Enter the final temperature of the water in Celsius");
Scanner input2 = new Scanner(System.in);
finalTemperature = input2.nextDouble();
double result;
result = weightofwater * (finalTemperature - initialTemperature) * 4184;
System.out.println("The energy needed is " + result + " Joules");
}
}