An odometer is an instrument used for measuring the distance traveled by a vehicle, such as a bicycle or car. It appears on a car’s dashboard together with the speedometer
Odometer
An odometer is an instrument used for measuring the distance traveled by a vehicle, such as a bicycle or car. It appears on a car’s dashboard together with the speedometer. Odometer is a Greek word that means path and measure. An odometer consists of a cog wheel that has no. of holes on its periphery. A proximity sensor is placed near the cog wheel’s periphery that generates train of pulses when holes and no-hole events occur in proximity of proximity switch. The proximity sensor may be replaced with transmitter-receiver pair (photo-transistor and photo-LED). The no. of pulses generated as a result of hole-no hole events are calibrated in terms of vehicle speed. When the speed is integrated over a period of time, it becomes mileage and total distance travelled by the vehicle. These information are displayed on vehicle’s dash board.
A simple odometer mileage program has been created in c++ so as to show the mileage calculations as given below:
main(void)
{
double R1=1,R2=0,R;
double Milage=0.5,Amount;
printf("\n\t\t\tMILEAGE REIMBURSEMENT CALCULATOR");
while(R1>R2)
{
printf("\n\n\tEnter beginning odometer reading => "); scanf("%lf",&R1);
printf("\n\tEnter ending odometer reading => "); scanf("%lf",&R2);
if(R1>R2)
{
printf("\n\tBegining Readings should be less than or equal to End Readings.");
printf("\nPl. try again.");
}
}
R = R2-R1;
printf("\n\n\tYou travelled %.2f miles. At $ %.2f per mile",R,Milage);
Amount = R*Milage;
printf("\n\tYour reimbursement is $ %.2f",Amount);
return(0);
}
Comments
Leave a comment