Menghitung Energi

Assalamualaikum, . .
Pagi in saya akan membagikan tentang cara menghitung eneri pada pemrograman java, .
Silahkan dicoba. . .

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);
}

}

Semoga bermanfaat, . .

Subscribe to receive free email updates:

0 Response to "Menghitung Energi"

Post a Comment