Website Summary Files Commits Branches @commit @diff @stats
path: root / Week02 / Exercise02 / main.cpp
blob: 4d4303737d48b3c31e85a70507274d1e30356ac2 (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
#include <iostream>
#include "temperature.h"

Temperature readTemperature() {
	double degrees;
	std::cin >> degrees;
	char scale;
	std::cin >> scale;

	Temperature t;
	switch (scale) {
		case 'C': t.fromCelsius(degrees); break;
		case 'F': t.fromFahrenheit(degrees); break;
		case 'K': t.fromKelvin(degrees); break;
	}

	return t;
}

void printTemperature(const Temperature& t) {
	std::cout << t.C << " C " << t.F << " F " << t.K << " K" << std::endl;
}

int main() {
	Temperature first = readTemperature(), second = readTemperature();

	printTemperature(first.Sum(second));

	return 0;
}