Skip to content

Commit d9e291c

Browse files
Merge pull request The-Young-Programmer#10 from Easter-Maxwell-01/main
added file : temperature calculator
2 parents 1f73699 + 802c62f commit d9e291c

File tree

1 file changed

+249
-0
lines changed

1 file changed

+249
-0
lines changed
Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
/*
2+
project status : 1
3+
Date : Oct 11, 2022
4+
Author : Easter Maxwell
5+
co-factor : The Young Programmer Nemonet (Nov 16, 2022)
6+
*/
7+
8+
/*'Error --1' is just a random error message*/
9+
10+
//control number output
11+
#include <iomanip>
12+
13+
//for system operations
14+
#include <windows.h>
15+
16+
#include <iostream>
17+
18+
using namespace std;
19+
20+
void standard_output()
21+
{
22+
int fahr;
23+
int order;
24+
int celsius;
25+
int lower_value;
26+
int upper_value;
27+
28+
cout << "\n";
29+
cout << "[+]Enter Order value : ";
30+
cin >> order;
31+
32+
cout << "\n";
33+
cout << "[+]Enter Lower Value : ";
34+
cin >> lower_value;
35+
36+
cout << "\n";
37+
cout << "[+]Enter Upper Value : ";
38+
cin >> upper_value;
39+
40+
/*enables 'fahr' to start printing from the lowest value*/
41+
fahr = lower_value;
42+
43+
cout << "\n";
44+
cout << "\t\t\t\t\t ";
45+
cout << "--- Temperature ---" << endl;
46+
47+
cout << "\n";
48+
cout << "\t\t\t\t\t "
49+
<< "+----------------------------+"
50+
<< "\n"
51+
<< "\t\t\t\t\t "
52+
<< "| Fahrenheit Celsius |"
53+
<< "\n"
54+
<< "\t\t\t\t\t "
55+
<< "+--------------|-------------+";
56+
57+
while (fahr <= upper_value)
58+
{
59+
/*Formula (Fahrenheit to Celsius)*/
60+
celsius = 5 * (fahr - 32) / 9;
61+
62+
cout << "\n";
63+
cout << "\t\t\t\t\t ";
64+
65+
cout << "| " << fahr << "\t\t " << celsius << " |";
66+
67+
cout << "\n";
68+
cout << "\t\t\t\t\t ";
69+
cout << "+--------------|-------------+";
70+
71+
/*increments fahrenheit by the 'order' value*/
72+
fahr = fahr + order;
73+
}
74+
75+
}
76+
77+
void user_specific_output()
78+
{
79+
string option;
80+
float fahr_input;
81+
float fahr_value;
82+
float celsius_input;
83+
float celsius_value;
84+
85+
cout << "\t\t\t\t\t "
86+
<< "--- Available Options ---" << endl;
87+
88+
cout << "\t\t\t "
89+
<< "\n"
90+
<< "\t\t\t "
91+
<< "+-----------------------------------------------------------+"
92+
<< "\t\t\t "
93+
<< "\n"
94+
<< "\t\t\t "
95+
<< "| Press F to convert temperature from Fahrenheit to celsius |"
96+
<< "\t\t\t "
97+
<< "\n"
98+
<< "\t\t\t "
99+
<< "| --------------------------------------------------------- |"
100+
<< "\t\t\t "
101+
<< "\n"
102+
<< "\t\t\t "
103+
<< "| Press C to convert temperature from Celsius to Fahrenheit |"
104+
<< "\t\t\t "
105+
<< "\n"
106+
<< "\t\t\t "
107+
<< "+-----------------------------------------------------------+";
108+
109+
cout << "\n\n";
110+
cout << "[:]Enter Option : ";
111+
cin >> option;
112+
113+
if (option == "C" || option == "c")
114+
{
115+
cout << "\n";
116+
cout << "[+]Enter Temperature in Celsius : ";
117+
cin >> celsius_input;
118+
119+
/*Formula (Celsius to Fahrenheit)*/
120+
fahr_value = (9.0 / 5.0) * celsius_input + 32;
121+
122+
cout << "\n";
123+
cout << "\t\t\t\t\t ";
124+
cout << "--- Result ---" << endl;
125+
126+
cout << "\n";
127+
cout << "\t\t\t\t\t "
128+
<< "+----------------------------+"
129+
<< "\n"
130+
<< "\t\t\t\t\t "
131+
<< "| Celsius Fahrenheit |"
132+
<< "\n"
133+
<< "\t\t\t\t\t "
134+
<< "+--------------|-------------+";
135+
136+
cout << "\n";
137+
cout << "\t\t\t\t\t ";
138+
cout << "| " << celsius_input << "\t | " << setprecision(3) << fahr_value << "\t |";
139+
140+
cout << "\n";
141+
cout << "\t\t\t\t\t ";
142+
cout << "+----------------------------+";
143+
144+
}
145+
146+
else if (option == "F" || option == "f")
147+
{
148+
cout << "\n";
149+
cout << "[+]Enter Temperature in Fahrenheit : ";
150+
cin >> fahr_input;
151+
152+
/*Formula (Fahrenheit to Celsius)*/
153+
celsius_value = 5 * (fahr_input - 32) / 9;
154+
155+
cout << "\n";
156+
cout << "\t\t\t\t\t ";
157+
cout << "--- Result ---" << endl;
158+
159+
cout << "\n";
160+
cout << "\t\t\t\t\t "
161+
<< "+----------------------------+"
162+
<< "\n"
163+
<< "\t\t\t\t\t "
164+
<< "| Fahrenheit Celsius |"
165+
<< "\n"
166+
<< "\t\t\t\t\t "
167+
<< "+--------------|-------------+";
168+
169+
cout << "\n";
170+
cout << "\t\t\t\t\t ";
171+
cout << "| " << fahr_input << "\t | " << setprecision(3) << celsius_value << "\t |";
172+
173+
cout << "\n";
174+
cout << "\t\t\t\t\t ";
175+
cout << "+----------------------------+";
176+
}
177+
178+
else
179+
{
180+
Sleep(500);
181+
cout << "\n[:]#Msg : Error --1" << endl;
182+
cout << "[:}Fault : Invalid option Input!" << endl;
183+
}
184+
185+
}
186+
187+
int main()
188+
{
189+
string user_input;
190+
191+
cout << "\t\t\t\t\t ";
192+
cout << "--- TEMPERATURE CALCULATOR ---";
193+
cout << "\n\n";
194+
cout<<"\n\t\tDeveloped By:";
195+
cout<<" Easter Maxwell (Oct 11, 2022)";
196+
cout<<"\n\t\t In Collaboration with:";
197+
cout<<" Nemonet (TYP) (Nov 16, 2022)";
198+
cout<<"\n\n\n\n";
199+
200+
cout << "\t\t\t\t\t"
201+
<< "+------------------------------------+"
202+
<< "\t\t\t\t\t"
203+
<< "\n"
204+
<< "\t\t\t\t\t"
205+
<< "| Press 0 to display standard input |"
206+
<< "\t\t\t\t\t"
207+
<< "\n"
208+
<< "\t\t\t\t\t"
209+
<< "| ---------------------------------- |"
210+
<< "\t\t\t\t\t"
211+
<< "\n"
212+
<< "\t\t\t\t\t"
213+
<< "| Press X to display specific output |"
214+
<< "\t\t\t\t\t"
215+
<< "\n"
216+
<< "\t\t\t\t\t"
217+
<< "+------------------------------------+"
218+
<< "\n\n";
219+
220+
cout << "[:]Enter option : ";
221+
cin >> user_input;
222+
223+
if (user_input == "0" || user_input == "o" || user_input == "O")
224+
{
225+
Sleep(500);
226+
227+
/*display this function*/
228+
standard_output();
229+
}
230+
231+
else if (user_input == "X" || user_input == "x" || user_input == "*")
232+
{
233+
Sleep(500);
234+
235+
/*display this function*/
236+
user_specific_output();
237+
}
238+
239+
else
240+
{
241+
Sleep(500);
242+
cout << "\n[:]#Msg : Error --1" << endl;
243+
cout << "[:}Fault : Invalid option Input!" << endl;
244+
}
245+
246+
return -1;
247+
248+
}
249+

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy