kali ini saya akan membagikan cara menghitung energi dengan pemrograman java, ada yang udah pernah nyoba manualnya tidak, . .? Kalo belum, berarti sama. . :-)
Silahkan dicoba coding dibawah ini, . .
import java.util.Scanner;
public class CalculatingEnergy {
public static void main(String[] iriahus) {
final double MASS_TO_ENERGY = 4184.0;
@SuppressWarnings("resource")
Scanner s = new Scanner(System.in);
System.out.print("Enter the amount of water in kg: ");
double M = s.nextDouble();
System.out.print("Enter the initial temperature: ");
double t0 = s.nextDouble();
System.out.print("Enter the final temperature: ");
double t1 = s.nextDouble();
double Q = M * (t1 - t0) * MASS_TO_ENERGY;
System.out.println("The energy needed is " + Q);
}
}
Thank for visiting. . . Semoga bermanfaat, ..
0 Response to "Menghitung Energi"
Post a Comment