Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

JAVA Programming (Science: calculating energy) Write a program that calculates t

ID: 655353 • Letter: J

Question

JAVA Programming

(Science: calculating energy) Write a program that calculates the energy needed to heat water from an initial temperature to a final temperature. Your program should prompt the user to enter the amount of water in kilograms and the initial and final temperatures of the water. The formulato compute the energy is Q- M (final Temperature initial Temperature) 4184 where Mis the weight of water in kilograms, temperatures are in degrees Celsius. and energy Qis measured in joules. Here is a sample run: Enter the amount of water in kilograms: 55.5 Pune Enter the initial temperature: 3.5 Enter the final temperature: 10.5 PEnter The energy needed is 1625484.0

Explanation / Answer


import javax.swing.*;

public class CalculatingInterest {
public static void main(String[] args) {
String annualInterestRateString = JOptionPane.showInputDialog("Enter balance");


double annualInterest Rate =Double.parseDouble(annualInterestRateString);


String annualInterestRateString = JOptionPane.showInputDialog("Enter annual interest rate");

int annualInterestRate = Integer.parseInt(annualInterestRateString);

double interest = balance * (annualInterestRate / 1200);
interest = (int)(monthlyPayment * 100) / 100.0;


String output = "The interest is " + interest + ";

JOptionPane.showMessageDialog(null, output);
}
}