Questions tagged [unit-conversion]
Code whose primary purpose is to convert quantities from one system of measurement to another
105
questions
23
votes
4
answers
2k
views
Celsius → Fahrenheit conversion table
It's harder to do than criticize. Here's my attempt to implement a Celsius-to-Fahrenheit conversion table in C++.
...
22
votes
3
answers
3k
views
SI unit converter
I recently started "coding" and this is one of my first "projects". It is supposed to be an SI converter where you can type a value, its unit and the unit to which you want it to be converted.
...
14
votes
5
answers
5k
views
Temperature unit conversion (C,F,K) in C++ - follow-up
Link to my first question:
Converting Celsius and Fahrenheit in C++
I've improved my code, following @Jamal's recommendations. I hope I did everything right. The only thing I didn't get was putting ...
14
votes
3
answers
6k
views
Python 3 - simple temperature program
I have been teaching myself Python (as well as Tkinter) and today one of the sites I was reading, asked us to write a program to covert one value from Fahrenheit to Celsius, once - an easy three line ...
14
votes
5
answers
1k
views
Struct for angles
I would like to ask about the code below:
...
12
votes
4
answers
4k
views
Temperature conversion code
I am currently creating a program that can convert different units of measurement for temperature. It includes conversions for Celsius, Fahrenheit, kelvin and gas mark. Can someone tell me how I could ...
11
votes
3
answers
3k
views
Convert a string like 4h53m12s to a total number of seconds in JavaScript
At the moment I have this:
...
11
votes
3
answers
162
views
Mass and length calculator using Perl 6 custom operator
I am studying chemistry in the university, and then I try to write all the things in the textbook with Perl6 or Perl, like balancing the chemical formula or other process!
Then I encountered the ...
10
votes
9
answers
2k
views
Simple temperature converter in C
I have just begun to learn the C language and wanted to start off small with a temperature conversion calculator. The program works, and I'm looking for feedback on do's and don'ts as I am sure there ...
9
votes
5
answers
2k
views
Comparing Old vs. New: Temperature Converter
I made this temperature converter when I first started getting into Python. After a year of regular programming on my own I decide it was time to revisit my old program. Now that I finished my first ...
9
votes
8
answers
4k
views
Temperature conversion application
I'm two months in a programming course and our instructor told us we should think about building real-world applications as to gain valuable experience. I got the idea of doing a simple temperature ...
8
votes
2
answers
3k
views
Fahrenheit and Celsius converter in Rust
I made a program that converts between Celsius and Fahrenheit. Is there any way that I could make this code more efficient and cleaner?
...
8
votes
3
answers
3k
views
Temperature converter using "switch" statement
I wrote a program to convert temperature into different units, where the users have to put a space between temperature and unit:
23 f, 34 c, 45 k
...
8
votes
1
answer
4k
views
Python beginner code for a currrency converter
I am also pretty new to Python so I want to show my code for a very small currency converter with an Tkinter GUI.
The code does what I want, but now I want to optimize it and find new "next level" ...
7
votes
4
answers
7k
views
Converting between miles, meters, inches, yards and feet
I am trying to use a class to convert between miles, meters, inches, yards and feet. My instructor told me that
I have way too many functions
My return statements are not storing any values and
My ...
7
votes
4
answers
7k
views
Currency converter using MVC pattern in C++ & QT
While understanding the MVC pattern, I came across this particular article. I thought to implement it using the C++/QT library.
The intent over here is to implement/use MVC concepts in correct way. ...
7
votes
2
answers
3k
views
Simple OOP currency converter
I am learning about OOP so it would be great if you can give me feedback on how to improve my code and OOP design.
This is a currency converter. Firstly, it will call a method to add 2 currencies and ...
7
votes
2
answers
183
views
Pythonic attempt at conversion of length
I'm trying to learn Python, so I started with a program to convert length units, mixing imperial and metric. First I wrote a bunch of small simple functions, but then I wanted to solve the issue of ...
7
votes
2
answers
345
views
Unit conversion program into metre and stored input
I was curious as to how I'd be able to make this much clearer to read because from my perspective I understand what does what but how does it look to a third party? Also how are my object / method ...
7
votes
2
answers
8k
views
Convert geodetic coordinates to geocentric (cartesian)
I'd like to retain as much float precision as possible without having to resort to specialized libraries so I need this code to work with only standard modules.
I'm doing this in QGIS where ...
7
votes
2
answers
241
views
Java command-line API client to fetch Bitcoin exchange rates
I am building a simple Java command-line application. And I want to know the best practice and make my code clean. Can anybody suggest to me how many different classes I can make and what more method ...
6
votes
4
answers
1k
views
Bytes to binary conversion function
I created a quick function to convert n bytes into binary for my student.
She is not on that level yet, but I think it would be best for her if my demonstrative ...
6
votes
3
answers
2k
views
Python 3 - simple temperature program version 1.3
Thank you to everyone for the feedback provided to the initial version of this program posted here.
Please find below the newest version, revised based on the comments provided, for review and ...
6
votes
3
answers
3k
views
Fahrenheit / Celsius temperature converter
This is a simple bash script (hopefully with a little style as well) for converting temperatures from Fahrenheit to Celsius and vice versa.
...
6
votes
1
answer
947
views
Converting Celsius and Fahrenheit in C++
I've made my first little program written in C++ and was wondering if anyone could evaluate it and suggest some improvements. No copy paste. I was wondering if I can do something with my little ...
6
votes
3
answers
1k
views
Animal Age Calculator
Could someone suggest ways to simplify this code, or any other tips? All help is much appreciated. Moreover, should I comment code above or below the line of code (I have to comment as this is a ...
6
votes
4
answers
276
views
Simple Temperature Converter 2 in C
I finally got around to redoing my Temperature conversion program. I incorporated many elements of everyone's comments, and am uploading the finished program. Any new, or problems that I missed? Maybe ...
6
votes
2
answers
597
views
Android unit converter
I am developing a unit converter application for Android. The application is working correctly, but my problem is with the optimization. Is there a way to somehow optimize the code?
I have different ...
6
votes
2
answers
3k
views
Angular control for inputting latitude and longitude with validation
I've built a custom control to handle user input in a human-readable format, but save in a machine-format.
It needs to have input validation, and to convert UI-input to a base format.
I'm interested ...
5
votes
2
answers
504
views
"Nice Angles" - Code Eval challenge
Out of fun, I solved "Nice Angles" challenge on CodeEval in C# 4.0:
CHALLENGE DESCRIPTION:
Write a program that outputs the value of angle, reducing its
fractional part to minutes and ...
5
votes
3
answers
25k
views
Unit converter in Python
I am new to programming and I am trying to make a simple unit converter in python. I want to convert units within the metric system and metric to imperial and vice-versa. I have started with this code ...
5
votes
3
answers
347
views
Templatizing a Timer class
I'm making a timer class in C++. This is the overview:
...
5
votes
2
answers
696
views
Celsius and Fahrenheit Conversion
This is a school project submitted last year, and I've been looking over it and trying to figure out what I could improve on. I know I used celsiusInput and ...
5
votes
1
answer
263
views
Pretty print uptime given seconds and omit unnecessary strings
Given an integer number of seconds, return a string which represents in human readable format the number of days/hours/minutes/seconds that are equivalent.
...
5
votes
2
answers
118
views
Code to support different measurement systems
I am developing an application in which the user can use different measurement systems. Currently,
there is support for the metric and imperial measurement systems. To support these systems, I wrote ...
5
votes
1
answer
7k
views
Currency Converter in Python 3
Beginner Python developer here.
I was tinkering around with Python and decided to build a currency converter. It takes in input from the user and prints out the converted currency values. The fixer.io ...
5
votes
2
answers
115
views
Custom data type - "Binary" Float (0-1.0)
In my current game I have the need for values ranging from 0 to 1, or from -1 to 1. The values should never exceed this threshold, so instead of constantly validating the values I made a custom data ...
5
votes
1
answer
196
views
Temperature converter app
I'm learning Ruby and as an exercise I decided to build this little temperature converter app (C to F, F to C, F to K, etc). Looking back at it, it's pretty much just a bunch of boilerplate code. Any ...
5
votes
1
answer
3k
views
Currency converter built with AngularJS
I am fairly new to AngularJS and I am trying to improve my knowledge of this JavaScript Framework by building small real-world web-apps.
In this case, I have built a currency converter app with ...
5
votes
0
answers
182
views
Converting between cooking measurements
I've made an Android app that converts between cooking measurements, taking into account the type of product you use (that way it can convert between mass and volume by using the density). What are ...
4
votes
2
answers
159
views
Two classes to avoid confusion when handling degrees and radians
Experimenting with operator overloading for the first time. Based on my reading, it appears to be a bit of a minefield.
Have I fallen into any traps?
...
4
votes
1
answer
1k
views
Java Temperature Converter
I have made a program that converts Celsius to Fahrenheit and Fahrenheit to Celsius. How is my code?
...
4
votes
2
answers
2k
views
Parsing and converting DMS Coordinates from String to Double
I have some coordinates looking like
N47° 15' 36.75",E011° 20' 38.28",+001906.00
and I've created a class to parse and convert them to Double:
...
4
votes
1
answer
311
views
fasm convert hex byte to binary string
This fasm x64 (Linux) code seems very crude and repetitive, but it gets the job done. How could I perform this task in a more idiomatic manner?
...
4
votes
1
answer
447
views
Simple unit converter and shipment builder
My first python program top to bottom used for work.
First it converts units from imperial to metric and vice versa, then adds the dimensions to a shipment and prints the shipment. When you do a new ...
4
votes
1
answer
93
views
Converting between different units of temperature
The task is to convert a temperature in a list of Fahrenheit, Celsius, or Kelvin to the two other temperatures in the list.
Here is my code:
...
4
votes
3
answers
4k
views
Swing Temperature Converter
I made a simple temperature converter to serve as an introduction to swing. I used Eclipse WindowBuilder and did not attempt to make the components more modular. I'm curious as to how you guys would ...
4
votes
1
answer
292
views
Performing unit conversions using intermediate conversions
Challenge:
Two input files are given The first contains |N| ratios in the form of
two labels and a ratio:
USD, GBP, 0.69
Meter, Yard, 1.09
YEN, EUR, 0.0077
GBP, YEN, 167.75
...
4
votes
3
answers
278
views
Convert length of time to appropriate unit
I have a time, in seconds, which has the possibility to be very large. I wish to convert said time into the "appropriate" rounded, readable format.
I already have code which achieves this, however it'...
4
votes
2
answers
143
views
Convert light-years to other representations
the code is very messy, long and I am looking how to shorten it and/or simplify it. There are a lot of repeated variables, for example; 'hourToDay' and then 'hourToDay1', 'hourToDay2' and so forth. ...