Answer to Question #256013 in C# for Umar farouk

Question #256013
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 * (finalTemperature – initialTemperature) * 4184 where M is the weight of water in kilograms, temperatures are in degrees Celsius, and energy Q is measured in joules.
1
Expert's answer
2021-10-28T13:13:35-0400
using System;


namespace Questions
{
    class Program
    {
        static void Main()
        {
            Console.Write("Weight of a water: ");
            double weightOfWater = double.Parse(Console.ReadLine());


            Console.Write("\nInitial temperature: ");
            double initialTemperature = double.Parse(Console.ReadLine());


            Console.Write("\nFinal temperature: ");
            double finalTemperature = double.Parse(Console.ReadLine());


            double energy = weightOfWater * (finalTemperature - initialTemperature) * 4184;


            Console.WriteLine(
                string.Format("\nThe energy {0} joules needed to heat {1}kg of a water from a {2} to  {3} Celsius", 
                energy, weightOfWater, initialTemperature, finalTemperature));


            Console.ReadKey();
        }
    }


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS