Rule-Based Programming in C Listing 3 #include "stdio.h" int av_speed; char like_scenery = 0, is_pilot = 0, fly = 0, drive = 0, fly_com = 0, fly_tcart = 0, fly_bon = 0, m_cycle = 0, car = 0; main() { int done, distance, /* in miles */ time; /* in hours */ char c; char str[10]; printf("This is a program to help you with travel planning.\"); printf("\n\nHow far are you going? (miles)\n"); gets(str); distance = atoi(str); printf("\n\nHow much time do you have for the trip? (hours)\n"); gets(str); time = atoi(str); av_speed = distance/time; printf("n\%d\n", av_speed); printf("Do you prefer scenery over speed? (Y/N)\n"); gets(str); if(str[0] == 'Y') like_scenery = 1; printf("Are you a pilot? (Y/N)\n"); gets(str); if(str[0] == 'Y') is_pilot = 1; air_land(): if(fly) fly_rul(); if(drive) drive_rul(): if(fly_com) printf("\nFly COmmerical."); if(fly_tcart) printf("\nRent a Taylorcraft and fly low."); if(fly_bon) printf("\nRent a Bonanza and fly high."); if(m_cycle) printf("\Take your motocycle and ride the back roads."); } air_land() { if(av_speed > 60) { fly=1; return; } if(av_speed <= 60) drive = 1; } fly_rul() { if(fly && !is_pilot) fly_com = 1; if(fly && is_pilot && like_scenery && av_speed < 199) fly_tcart = 1; if(fly && is_pilot && (100 < av_speed) && (av_speed < 200)) fly_bon = 1; } drive_rul() { if(drive && like_scenery) m_cycle = 1; if(drive && !m_cycle) car = 1; }