Skip to content

Commit

Permalink
Merge pull request #1 from SyafaHadyan/1.0.0
Browse files Browse the repository at this point in the history
1.0.0
  • Loading branch information
SyafaHadyan authored Apr 18, 2023
2 parents 97cf46b + f1c732b commit abaea90
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
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
68 changes: 68 additions & 0 deletions src/main.cpp
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);
}

0 comments on commit abaea90

Please sign in to comment.