Skip to main content

Questions tagged [unit-conversion]

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

Filter by
Sorted by
Tagged with
3 votes
1 answer
103 views

I've been following the rust book, and I made a Celsius to Fahrenheit converter as it advised me. After a bit, I came up with this code; however in my opinion, there's a lot of unnecessary parts that ...
icy icy's user avatar
  • 33
2 votes
1 answer
111 views

Problem Statement From the National Institute of Standards and Technology's Office of Weights and Measures, one can find a handy list of all the metric prefixes: e.g. Purpose Name Symbol Factor Name ...
SumNeuron's user avatar
  • 291
5 votes
3 answers
780 views

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 ...
dope_centipede's user avatar
0 votes
1 answer
157 views

I'm trying to learn Rust and for this reason I'm reading the Rust Book. It contains the following exercise: Convert temperatures between Fahrenheit and Celsius. Here's my take. Note I'm only using ...
DisplayName's user avatar
1 vote
1 answer
109 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
3 votes
2 answers
501 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
2 votes
2 answers
406 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
1 vote
2 answers
208 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
1 vote
2 answers
151 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
1 vote
1 answer
135 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
0 votes
2 answers
318 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
2 votes
0 answers
369 views

Problem statement: Write a program that converts all given temperatures from a given input temperature scale to a given output temperature scale. The temperature scales to be supported are Kelvin, ...
Christian Hujer's user avatar
5 votes
3 answers
529 views

I'm making a timer class in C++. This is the overview: ...
Alex CB's user avatar
  • 175
2 votes
2 answers
249 views

So I'm trying to understand the concept of descriptors and gathered some code together and made an exampel out of different sources. Like the offical documentation and StackOverflow answers. I'd hope ...
Thingamabobs's user avatar
2 votes
2 answers
204 views

I have been learning python since being in lockdown, this is the first Tkinter application I've built without consulting the internet or seeking help anywhere. It is a time converter where you can ...
Sheik-Yabouti's user avatar
2 votes
3 answers
450 views

I am looking to improve the performance of my code through best practices and cleaner code. My goal here is just to perform a conversion whenever there is a keyup. But I noticed that my code looks ...
ARNON's user avatar
  • 441
6 votes
4 answers
2k views

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 ...
Edenia's user avatar
  • 1,588
4 votes
1 answer
1k views

I have made a program that converts Celsius to Fahrenheit and Fahrenheit to Celsius. How is my code? ...
user avatar
6 votes
2 answers
198 views

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 ...
Destroyer's user avatar
  • 459
4 votes
1 answer
349 views

Introduction I am recently learning Rust by reading The Rust Programming Language (a.k.a. the book). I have finished the first three chapters so far, and this is my attempt for the first exercise ...
L. F.'s user avatar
  • 9,715
3 votes
1 answer
596 views

This code is a purely for-fun project and it comes from this challenge at freeCodeCamp. This is simply an algorithm challenge which is usually meant for JavaScript, but I decided to perform in C. It ...
the_endian's user avatar
  • 1,333
6 votes
2 answers
474 views

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 ...
AlanK's user avatar
  • 63
4 votes
1 answer
392 views

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? ...
the_endian's user avatar
  • 1,333
6 votes
2 answers
3k views

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 ...
ANeves's user avatar
  • 2,982
7 votes
2 answers
406 views

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 ...
forhadmethun's user avatar
4 votes
2 answers
308 views

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? ...
pingu's user avatar
  • 173
1 vote
1 answer
273 views

I wrote a simple currency converter in Python. Right now, my currency converter converts using the last available rate or converts using a specific date. Looking for: I'd appreciate any tips about ...
user avatar
4 votes
2 answers
205 views

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. ...
Hezekiah Sawyer's user avatar
11 votes
3 answers
4k views

At the moment I have this: ...
Dirk Boer's user avatar
  • 640
3 votes
2 answers
306 views

This is a follow up question on this post This is what I changed on my previous code: I use Exchanger and PairCurrency class ...
Nguyen's user avatar
  • 105
7 votes
2 answers
3k views

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 ...
Nguyen's user avatar
  • 105
2 votes
1 answer
177 views

I just started learning OOP from Mosh on YouTube and I looked for easiest exercises to practice. Can I get a feedback on my code please? What I did wrong and what I should change? In the code there ...
claudiu's user avatar
  • 31
6 votes
3 answers
2k views

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 ...
J Karle's user avatar
  • 221
15 votes
3 answers
7k views

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 ...
J Karle's user avatar
  • 221
4 votes
0 answers
779 views

I found a Go language code to do RGB to YCbCr conversion from here! I ported it to Java: ...
lucky1928's user avatar
  • 173
6 votes
0 answers
211 views

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 ...
Jeroen Vannevel's user avatar
5 votes
1 answer
617 views

I have some enum classes for units, like Weight units (KG and LB). I am translating the code to Qt C++ from Java, and I'm wondering what the best way to do this is as enums cannot have constructors in ...
Django's user avatar
  • 195
4 votes
1 answer
319 views

I’m learning F# and trying to find a more ‘functional’ way to code a simple program that retrieves the price of BTC and calculates the EUR value of an amount of Bitcoin. ...
MmM's user avatar
  • 419
1 vote
1 answer
141 views

This is what I came up with, but I'm not sure if: putting it in Class is the best approach multiple repeats (this.val etc.) are acceptable there is a better ...
Dom's user avatar
  • 131
3 votes
2 answers
384 views

I was doing an exercise in PHP, and it works perfectly, no problems. But I think that maybe I coded it so long, and I think it can be shorter than it is now, but I don't know how to make it shorter ...
Adrián Jaramillo's user avatar
3 votes
1 answer
366 views

Just on a chapter 3 of Rust Book so not much good in Rust. so tried to implement a simple temprature calculator as suggest in this chapter. so i would like you guys to point anything you feel ...
MAK's user avatar
  • 181
2 votes
2 answers
409 views

I have written a little program that calculates the time by given strings. A time string in the context of this program consists of a number and a following letter that can be s, m, h, or d. You can ...
Dexter Thorn's user avatar
  • 2,174
4 votes
1 answer
397 views

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 ...
Rohit's user avatar
  • 1,076
8 votes
2 answers
4k views

I made a program that converts between Celsius and Fahrenheit. Is there any way that I could make this code more efficient and cleaner? ...
bobby's user avatar
  • 83
3 votes
3 answers
181 views

I'm a bit of a beginner when it comes to Java, and I created this small code to help me grasp a few small subjects. It allows its user to convert a radical to a degree measure and a degree measure to ...
avavstack's user avatar
7 votes
2 answers
438 views

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 ...
Ulivax's user avatar
  • 117
4 votes
1 answer
156 views

I started learning Rust a few hours ago with the Rust Book (2018 edition) and as part of one of the exercises decided to make a temperature converter. I wanted to make sure it handled all inputs ...
Arnav Borborah's user avatar
5 votes
2 answers
163 views

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 ...
user avatar
2 votes
0 answers
93 views

This is the continuation of the questions raised in this thread I did include the improvements that were mentioned but still feel like, I do more copies than I need to. Also I am unsure about the ...
CD86's user avatar
  • 173
4 votes
1 answer
167 views

I wrote a small type-rich MKS Unit system for the consistent and safe calculation of physical units in everyday use. I realized some operators' implementations via the Barton-Nackman trick while ...
CD86's user avatar
  • 173