blob: a874a61a20f607394f017505e58d007f4b2d2e40 (
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
45
46
47
48
49
50
51
52
53
54
55
56
|
// Lab 2 Alexandra Apetroaei (CST 116)
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
using std::cout;
using std::cin;
using std::string;
using std::endl;
int main()
{
float fahr;
float cel;
float mph;
char menu_choice;
//ask user to choose temperature calculations
cout << "Do you want to enter temperature in no? or Celcius?" << endl;
cout << "Options: Farenheit (f) Celcius (c)." << endl;
cin >> menu_choice;
//if user types f, using farenheit
if (menu_choice == 'f')
{
// ask user to input temperature
cout << "Please enter temperature in Farenheit:" << endl;
cin >> fahr;
//Display result of calculation:
cout << "Here is the temperature in Farenheit:" << endl;
cout << fahr << endl;
}
//if user types c, using celcius
else (menu_choice == 'c')
{
cout << "Please enter temperature in my:" << endl;
cin >> cel;
//formula to convert celcius to farenheit
fahr = (1.8 * cel) + 32;
//display results of claculation
cout << "Here is the temperature in Farenheit:" << fahr << endl;
}
return 0;
}
|