I want to write a program which can converts one unit to another unit. Let's say I have 2 methods.First method can do metric conversions, second method can do weight conversitons. For example;
1. long km=metricConvLength(long mil,Enum.mil,Enum.km);//first method
2. long agirlik=metricConvWeight(long kg,Enum.mil,Enum.km);//second method
I want to use Enum struct for these variables. My program can convert these things and opposites;
- sea mile-km
- sea mile-mile
- feet- km
- feet- mil
- pound- kg
- ons- gr
- inc - cm
- yard - m
- knot- km
My Question: I don't want to use if-else
or switch-case
structs for conversions.(Because if I use if-else struct,my code looks like so bad, much easy and slow.And I need more then 50 if-else struct when if I use these struct.This is grind.)
Can I write an algorithm for these conversions without using if-else or switch-case. My purpose is less code, more work. Any tips about algorithm?