Hi,
I'm having trouble with doing conversion from US Distances to Meteric system. I'm sure i have my math right but i keep having issue with floats/ints/doublt.
That is my code of converting to meter from US. I start by converting everything to inches then convert inches to centimeters. After that i start converting from centimeters to KILOM. I try to get the remainder of how many Inch would be left over from KILOM and i get this error: error C2296: '%=' : illegal, left operand has type 'float'
Unless I'm going about this in the wrong direction please let me know!
*** EDIT ***
Okay i finally got it figured out and its converting correctly. I had to fix some math errors and what not. Now my finally issue is when it runs through the code I don't know how to make it output centimeter in decimals. The reason being is because the operate % won't allow me to use double nor floats.
I don't know how to get around this at the moment any help would be nice.
Well, what i would do is ask weather u want want to convert from us or metric so its both ways. Create a variable that stands for lets say(in us) inches and feet. Ask and create a switch statement to convert FROM what. so the var convert from decides look belo.
switch(convertfrom)
case "inches" : .........
break;
case "feet" : .........
break:
than in each one creat ANother Switch for a conveersion for what so this would be it
switch for wat starting measurement
case inches:
switch(endmeasurement)
case feet:
switch end measurement.
ill try to post a full code for this later using inches, feet, yards, meter, centimeter, and kilometer. just give me like an hour to eat first lolz
haha well actually my assignment wants me to ask for all 3 Miles Feet Inches then covert those into Metric which is : Kilometers, meters, cenitmeters.
so basicly input = miles feet inches
output = KM meters and centimeters.
They want it all to be converted
(ya thats my next part i must do to covert meteric to US which i will write in seperate code. I just wanted to get this float issue worked out then I can write the other code.)
basicly it will look like this:
1. Print a right triangle
2. Test to see if a number is a Fibonacci number
3. Convert from U.S. distance to metric distance
4. Convert from metric system to U.S. distance
5. Convert from Celsius to Fahrenheit
6. Exit program
_________________________________________________________
Your choice (1-6): 4
Enter an integer number of kilometers. Km=: 1
Enter an integer number of meters. m=: 1
Enter a decimal number of centimeters. cm=: 60867.42
1 kilometer 1 meter 60867.4219 centimeters =
1 mile 1 foot 1.0000 inch
_______________________________________
im just having problems getting the actual convertion to output correctly
lol i don take programming calss, im only in middle school so i have no idea. I do this for fun, but u inspired me to make a converter.
and u can do that code just cut that switch/case and do all the operations good luck :>
Well see that is my problem my code i have wrote up right there should do that job but for some reason inches2cenimeters %= 100000; is an illegal operation :(
im unable to run the program cuz of stupid errors dealing with my computer but it does compile correctly any opinions?
*** EDIT ***
Okay i finally got it figured out and its converting correctly. I had to fix some math errors and what not. Now my finally issue is when it runs through the code I don't know how to make it output centimeter in decimals. The reason being is because the operate % won't allow me to use double nor floats.
I don't know how to get around this at the moment any help would be nice.