diff options
author | 2024-03-10 21:50:38 +0600 | |
---|---|---|
committer | 2024-03-10 21:50:38 +0600 | |
commit | 9bb1850eb74237917c3ff8d3ab8315f3c196ff73 (patch) | |
tree | 60df5b0ca119515de1d9a456d570b250baf4b5da /main.cpp | |
parent | 0be48808422176133d21147d0dbbeeefdc3d4dac (diff) | |
parent | a2d29e8b76d3969e7c5f4f4509abf92727585a1b (diff) | |
download | entropy-calc-9bb1850eb74237917c3ff8d3ab8315f3c196ff73.tar.gz entropy-calc-9bb1850eb74237917c3ff8d3ab8315f3c196ff73.zip |
Merge branch 'main' into vscode
Diffstat (limited to 'main.cpp')
-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; } |