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 reads the subtotal and the gratuity rate, then computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

Write a program that prompts the user to enter the min- utes (e.g., 1 billion), and displays the number of years and days for the minutes. For simplicity, assume a year has 365 days