Share Your Experience: Take the 2024 Developer Survey

Questions tagged [unit-conversion]

Code whose primary purpose is to convert quantities from one system of measurement to another

105 questions
Filter by
Sorted by
Tagged with
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++. ...
• 144k
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. ...
• 221
6k 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 ...
• 303
7k 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 ...
• 211
1k views

• 141
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 ...
• 123
4k views

Convert a string like 4h53m12s to a total number of seconds in JavaScript

At the moment I have this: ...
• 650
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 ...
• 211
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 ...
• 725
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 ...
• 183
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 ...
• 229
4k 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? ...
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 ...
• 163
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" ...
• 337
8k 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 ...
• 71
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. ...
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 ...
• 105
402 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 ...
• 117
9k 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 ...
• 385
356 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 ...
• 227
2k 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 ...
• 1,568
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 ...
• 211
427 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 ...
• 63
4k 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. ...
• 379
1k 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 ...
• 303
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 ...
280 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 ...
• 725
600 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 ...
• 197
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 ...
• 2,882
198 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 ...
• 11.6k
683 views

Temperature unit conversion in Rust

Below is a simple Rust program which inter-converts temperature between the Celsius scale and the Fahrenheit scale. It takes two inputs: scale referring to the temperature scale of the next input the ...
505 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 ...
• 195
27k 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 ...
473 views

Templatizing a Timer class

I'm making a timer class in C++. This is the overview: ...
• 175
722 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 ...
126 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 ...
• 477
277 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. ...
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 ...
• 153
120 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 ...
212 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 ...
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 ...
• 151
254 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? ...
• 173
1k views

Java Temperature Converter

I have made a program that converts Celsius to Fahrenheit and Fahrenheit to Celsius. How is my code? ...
3k 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: ...
• 153
370 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? ...
• 1,343
480 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 ...
• 43
98 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: ...
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 ...
365 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 ...
• 1,066