diff options
author | 2024-03-09 00:29:25 +0600 | |
---|---|---|
committer | 2024-03-09 00:29:25 +0600 | |
commit | c237e0c92ecee53ed7352b83c69da9aabafcd26b (patch) | |
tree | d0d92184c70b590beef20065b0af0e9d7de5bb29 /main.cpp | |
parent | 6e2a2938c18ace9d12bc9135bba61bef20de44e4 (diff) | |
download | entropy-calc-c237e0c92ecee53ed7352b83c69da9aabafcd26b.tar.gz entropy-calc-c237e0c92ecee53ed7352b83c69da9aabafcd26b.zip |
calculation of total heat fixed
Diffstat (limited to '')
-rw-r--r-- | main.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
@@ -20,13 +20,25 @@ int main() double mass, fromTemp, toTemp; cout << "Enter the mass of the element (in Kg): "; - cin >> mass; + cin >> mass;
+ if (mass <= 0)
+ {
+ cout << "Mass must be a positive value" << endl;
+ return 0;
+ } cout << "Enter the initial temperature of the element (in K): "; cin >> fromTemp; cout << "Enter the final temperature of the element (in K): "; - cin >> toTemp; - - cout << "The total heat needed is: " << elements[choice - 1]->totalHeatNeeded(mass, fromTemp, toTemp) << " J" << endl; - - cout << "The total entropy change is: " << elements[choice - 1]->totalEntropyChange(mass, fromTemp, toTemp) << " J/K" << endl; + cin >> toTemp;
+ if (fromTemp > toTemp)
+ {
+ cout << "Initial temperature can not be greater than final temperature" << endl;
+ return 0;
+ } +
+ double totalHeat = elements[choice - 1]->totalHeatNeeded(mass, fromTemp, toTemp);
+ double totalEntropy = elements[choice - 1]->totalEntropyChange(mass, fromTemp, toTemp); + cout << "The total heat needed is: " << totalHeat << " J" << endl; + cout << "The total entropy change is: " << totalEntropy << " J/K" << endl;
+ return 0; } |