blob: 4218ca2256e06b9e0ce17b974b6c7058e8fab0d2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#define _USE_GMP
#include <iostream>
#include <vector>
#include "allElements.h"
using namespace std;
int main()
{
vector<baseElement*> elements = getAllElements();
cout << "Choose an element: " << endl;
for (auto i = 0UL; i < elements.size(); i++) {
cout << i + 1 << ". " << elements[i]->getElementName() << endl;
}
int choice;
cout << "Write the number of the element: ";
cin >> choice;
cout << endl << elements[choice - 1]->getElementName() << " Selected" << endl;
double mass, fromTemp, toTemp;
cout << "Enter the mass of the element (in Kg): ";
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;
if (fromTemp > toTemp) {
cout << "Initial temperature can not be greater than final temperature" << endl;
return 0;
}
double totalHeat = bigfloat_unwrap(elements[choice - 1]->totalHeatNeeded(mass, fromTemp, toTemp));
double totalEntropy = bigfloat_unwrap(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;
//thank you.. feel free to contribute here..:)
}
|