জাভা প্রোগ্রামিং পর্ব-১৪



2.16 (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 formula to compute the energy is Q = M * (final temperature – initial temperature) * 4184

where M is the weight of water in kilograms, temperatures are in degrees Celsius, and energy Q is measured in joules.

Code : File name-CalculatingEnergy.java
import java.util.*;
import javax.swing.*;
public class CalculatingEnergy {
    public static void main (String arg[]){
        double energy, weight, initialTemp, finalTemp, calculatEnergy;
        Scanner input =new Scanner(System.in);

        System.out.print("Enter Weight of water in kilogram: = ");
        weight =input.nextDouble();

        System.out.print("Enter initual tempereture in celsius: = ");
        initialTemp =input.nextDouble();

        System.out.print("Enter final tempereture in celsius: = ");
        finalTemp =input.nextDouble();

        calculatEnergy = weight*(finalTemp-initialTemp)*4184;
        System.out.print("The energy needed is: = "+calculatEnergy);
        }
    }

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle