-
Notifications
You must be signed in to change notification settings - Fork 1
/
convert.cpp
63 lines (57 loc) · 1.18 KB
/
convert.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "function.h"
#include "tool.h"
#include "const.h"
#include <iostream>
#include "iomanip"
void FUNC::unitcovert()
{
int unittype = 0;
cout<<green("Please choose: ")<<endl;
cout<<green("1: temperature")<<endl;
cin>>unittype;
if(unittype==1)
convertT();
else
{
cout<<red("Wrong Input!")<<endl;
exit(1);
}
}
void FUNC::convertT()
{
int Ttype = 0;
double rawdata = 0;
cout<<green("Please choose the unit: ")<<endl;
cout<<green("1: eV")<<endl;
cout<<green("2: K")<<endl;
cout<<green("3: Ry")<<endl;
cin>>Ttype;
cout<<green("Please input the number: ");
cin>>rawdata;
double UeV, UK, URy;
if(Ttype == 1)
{
UeV = rawdata;
UK = UeV * eV2K;
URy = UeV / Ry2eV;
}
else if(Ttype == 2)
{
UK = rawdata;
UeV = UK / eV2K;
URy = UeV / Ry2eV;
}
else if(Ttype == 3)
{
URy = rawdata;
UeV = URy * Ry2eV;
UK = UeV * eV2K;
}
else
{
cout<<red("Wrong Input!")<<endl;
exit(1);
}
cout<<"The temperature is:"<<endl;
cout<<setprecision(15)<<UK<<yellow(" K; ")<<UeV<<yellow(" eV; ")<<URy<<yellow(" Ry;")<<endl;
}