Updates:

Pivoting content: arts and crafts, electronics, technology, and a little dose of everything else! Every Monday and Thursday (hopefully)!

Important:

Working on kyaratar.com and other projects.

C# - Simple Unit Conversion

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

Lets build our first simple console application! Here we will familiarize ourself with the basic C# syntax and let the user convert simple measurements.


Simple Unit Conversion:

This simple unit conversion C# console appliation will figure out certain characteristics of the number you provide. This is a very basic application that will help you familiarize yourself with the C# syntax and basic understanding of logical thinking for programming.


Video Demonstration:

This is a really old video of me explaining and showing a demo of the C# console application.


Code Explanation:

The code is very basic and most probably unorganized. That's okay if your code is like mine or worse, because we will get better at organizing our code later on. One thing you can do to lessen the code is to use functions and methods and a switch case statement within a while loop. You can also make it more efficient by using different techniques of addition to implement multiplicatoin, division, and subtraction (but it doesn't matter that much because our computer CPUs are fast).

In the code below we are awaiting the user's input in either length, volume, or other menu selections. Then we do the conversion with simple arithmetic followed by then calculating the length, volume, and area with respect to the conversions available. The reason for so many if and while statements is because I'm treating it as a state machine (a Moore state machine). Once we the user goes through all the states, defined by the while loops, we repeat the beginning while loop over again.


Code:

The code is relatively short!

Show Code

Hide Code


Thank You:

Wasn't that simple? I wish you luck with programming in C#.

Tags: Computer Science, C#

Comments powered by CComment