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.

(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. 
#Beginner
In gcc c++ compiler using namespace std;


#include<iostream>
using namespace std;

int main()
{
float M,finalTemperature,initialTemperature;
cout<<"Enter te amount of water in kilograms :";
cin>>M;
cout<<"Enter the initial temperature :";
cin>>initialTemperature;
cout<<"Enter te finalTemperature :";
cin>>finalTemperature;
float Q=M*(finalTemperature-initialTemperature)*4184;
cout<<"The energy needed is "<<Q<<endl;
return 0;
}
copy


Output
Enter te amount of water in kilograms :4
Enter the initial temperature :30
Enter te finalTemperature :100
The energy needed is 1.17152e+06

[Program finished]

Need of Programmer

Need of Programmer

Comments

Popular posts from this blog

Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas: area = radius * radius * π volume = area * length

Write a program that prompts the user to enter two points (x1, y1) and (x2, y2) and displays their distance between them.The formula for computing the distance is

Area and perimeter of an equilateral triangle c++ program