-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SyafaHadyan/1.0.0
1.0.0
- Loading branch information
Showing
2 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# unit-converter | ||
Unit Converter | ||
# Unit Converter | ||
|
||
This is a unit converter that currently supports temperature conversions. More units such as distance, weight, and volume will be added soon. | ||
|
||
## Usage | ||
|
||
1. Run the program. | ||
2. Select the unit to convert by entering its corresponding letter. | ||
3. Enter the value of the unit to convert. | ||
4. The program will display the converted values. | ||
|
||
## Available Units | ||
|
||
### Temperature | ||
|
||
- Celcius | ||
- Fahrenheit | ||
- Kelvin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <cmath> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
|
||
char unit; | ||
char convert; | ||
double temp; | ||
|
||
cout << "(T)" << " " << "Temperature" << "\n" << endl; | ||
|
||
do | ||
{ | ||
|
||
cout << "Select unit:" << " "; | ||
cin >> unit; | ||
|
||
char unit_upper = toupper (unit); | ||
|
||
if (unit_upper == 'T') | ||
{ | ||
if (unit_upper == 'T') | ||
{ | ||
cout << "\n" << "(C) Celcius" << "\n" << "(F) Fahrenheit" << "\n" << "(K) Kelvin" << "\n" << endl; | ||
cout << "Enter C or F or or K:" << " "; | ||
cin >> convert; | ||
|
||
char convert_upper = toupper (convert); | ||
|
||
if (convert_upper == 'C') | ||
{ | ||
cout << "Enter temperature:" << " "; | ||
cin >> temp; | ||
|
||
cout << "Fahrenheit:" << " " << ((temp * 9)/5) + 32 << endl; | ||
cout << "Kelvin:" << " " << temp + 273.15 << endl; | ||
} | ||
else if (convert_upper == 'F') | ||
{ | ||
cout << "Enter temperature:" << " "; | ||
cin >> temp; | ||
|
||
cout << "Celcius:" << " " << ((temp - 32)*5)/9 << endl; | ||
cout << "Kelvin:" << " " << temp + 459.67 << endl; | ||
} | ||
else if (convert_upper == 'K') | ||
{ | ||
cout << "Enter temperature:" << " "; | ||
cin >> temp; | ||
|
||
cout << "Celcius:" << " " << (temp - 273.15) << endl; | ||
cout << "Fahrenheit:" << " " << ((temp - 273.15)*9)/5 + 32 << endl; | ||
} | ||
|
||
} | ||
} | ||
else | ||
{ | ||
cout << "\n" << "Invalid input" << "\n" << endl; | ||
} | ||
|
||
} | ||
while (true); | ||
} |