You need to format your code so it's readable ... it's as simple as putting it around some tags:
[code ]... your code here ...[/code ] |
Also,
how do i change this digital clock to car odometer
isn't a great question because it makes no sense. A digital clock gives the current TIME. A car odometer gives the DISTANCE TRAVELED by the car.
But perhaps it's some weird conversion you have to make as an exercise. In that case, can you give us some
examples of what the output should be? If I understand correctly, you're representing the current time as a float where 1 second = 1.0 mile and sub-second represents fraction of a mile (e.g., 100ms = 1/10 second = (1/10)(1.0 mile) = .1 mile).
So if the current time is
14:47:55.30
the Hour/Minute/Second/Sub-second components of the odometer reading are
1 2 3 4
|
Hour: 14 * (3600 Sec/Hr) * (1.0 Miles/Sec) = 50400 Miles
Minute: 47 * (60 Sec/Min) * (1.0 Miles/Sec) = 2820 Miles
Second: 55 * (1.0 Miles/Sec) = 55 Miles
Sub-Second: 0.3 * (1.0 Miles/Sec) = .3 Miles
|
and you take the sum of each component to get the final "odometer reading":
50400 + 2820 + 55 + 0.3 = 53257.3
and since the odometer format is 6 digits wide and 1 float digit long:
53257.3
should be
053257.3
Edited:
Thank you for the correction.