Facebook
From Bistre Hamerkop, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 245
  1. Scanner s = new Scanner(System.in);
  2.            
  3.            double g, Q, M = 0, iT, fT, finalTemp, initialTemp;
  4.            int amountOfWater;
  5.            System.out.println("Enter the amount of water in gram: ");
  6.            amountOfWater = s.nextInt();
  7.            System.out.println("Enter the initial temperature in Fahrenheit: ");
  8.            initialTemp = s.nextDouble();
  9.            System.out.println("Enter the final temperature in Fahrenheit: ");
  10.            finalTemp = s.nextDouble();
  11.            
  12.            M =amountOfWater/1000;
  13.            iT = (initialTemp - 32)/1.8;
  14.            fT = (finalTemp - 32)/1.8;
  15.            Q = M *(fT - iT)*4184;
  16.            
  17.            System.out.printf("The energy needed is " + Q);