⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 travel.c

📁 This is code tutorial for image processing include:histogram,sketon....
💻 C
📖 第 1 页 / 共 5 页
字号:
      printf("\n\t6. Arriving: %s", t->arrive_loc);
      printf("\n\t7. Time: %ld", t->arrive_time);
      printf("\n\t8. Go on to the next itinerary.");
      printf("\n\t9. Quit editing itinerary");
      printf("\n");
      printf("\n\tEnter the number to change:");
      gets(r);
      choice = atoi(r);
      switch(choice){

         case 1:
            printf("\nEnter the new departure date");
            get_mdy(&dummy);
            t->depart_date.month = dummy.month;
            t->depart_date.day   = dummy.day  ;
            t->depart_date.year  = dummy.year ;
            break;

         case 2:
            printf("\nLeaving:");
            gets(t->leave_loc);
            break;

         case 3:
            printf("\nAt:(24 hour time - no colon)");
            gets(s);
            t->depart_time = atoi(s);
            break;

         case 4:
            printf("\nVia:");
            gets(t->depart_via);
            break;

         case 5:
            printf("\nARRIVAL");
            get_mdy(&dummy);
            t->arrive_date.month = dummy.month;
            t->arrive_date.day   = dummy.day;
            t->arrive_date.year  = dummy.year;
            break;

         case 6:
            printf("\nArriving:");
            gets(t->arrive_loc);
            break;

         case 7:
            printf("\nAt:24 hour time - no colon)");
            gets(s);
            t->arrive_time = atoi(s);
            break;

         case 8:
            if(t->next == END_OF_LIST){
               printf("\nNo more itinerarys");
               not_finished = 0;
            }  /* ends if END_OF_LIST */
            else
               t = t->next;
            break;

         case 9:
            not_finished = 0;
            break;

         default:
            printf("\n\nSorry, cannot understand your");
            printf(" choice, try again.");
            break;

      }  /* ends switch choice */
   }  /* ends while not_finished */
}  /* ends edit_itinerary */
/*****************************************************/
/*****************************************************/
/*PAGE edit_daily_expenses

   This function allows the user to edit the
   daily expenses.
*/

edit_daily_expenses(ds)
   struct daily_struct *ds;
{
   char   r[L], s[L];
   int    choice, j, not_done, not_finished = 1;
   struct daily_struct *t;
   struct MDY_struct    dummy;

   t = ds;
   while(not_finished){
      printf("\n");
      printf("\n\t1.  Today is: %2d-%2d-%2d",
              t->today.month,
              t->today.day,
              t->today.year);
      printf("\n\t2.  Maximum Lodging: $%8.2f",
              dollars_of(t->max_lodging));
      printf("\n\t3.  M&IE: $%8.2f", 
              dollars_of(t->mie));
      printf("\n\t4.  Actual Lodging: $%8.2f",
              dollars_of(t->actual_lodging));
      printf("\n\t5.  POV Miles: %ld", t->pov_miles);
      printf("\n\t6.  POV Description: %s", 
              t->pov_desc);
      printf("\n\t7.  Rental Car Cost: $%8.2f",
              dollars_of(t->rental_car));
      printf("\n\t8.  Rental Car Description: %s",
              t->rental_car_desc);
      printf("\n\t9.  Taxi Cost: $%8.2f",
              dollars_of(t->taxi));
      printf("\n\t10. Taxi Description: %s ",
              t->taxi_desc);
      printf("\n\t11. Parking Cost: $%8.2f",
              dollars_of(t->parking));
      printf("\n\t12. Parking Description: %s",
              t->parking_desc);
      printf("\n\t13. Telephone Cost: $%8.2f",
              dollars_of(t->phone));
      printf("\n\t14. Telephone Description: %s",
              t->phone_desc);
      printf("\n\t15. Other Cost: $%8.2f",
              dollars_of(t->other));
      printf("\n\t16. Other Description: %s",
              t->other_desc);
      printf("\n\t17. Go on to the next day's expenses");
      printf("\n\t18. Quit editing daily expenses");
      printf("\n");
      printf("\n\tEnter the number to change:");
      gets(r);
      choice = atoi(r);
      switch(choice){

         case 1:
            printf("\nEnter date:");
            get_mdy(&dummy);
            t->today.month = dummy.month;
            t->today.day   = dummy.day;
            t->today.year  = dummy.year;
            break;

         case 2:
            printf("\nMax Lodging at TDY Point:");
            t->max_lodging = get_money();
            break;
      
         case 3:
            not_done = 1;
            while(not_done){
               printf("\nM&IE at TDY Point:");
               t->mie = get_money();
                     /* change - added 3 MIE values here
                        4-15-93 - DP */
               if(t->mie != MIE1  &&
                  t->mie != MIE2  &&
                  t->mie != MIE3  &&
                  t->mie != MIE4  &&
                  t->mie != MIE5){
                  printf("\nMust equal");
                  show_money(MIE1);
                  printf(", ");
                  show_money(MIE2);
                  printf(", ");
                  show_money(MIE3);
                  printf(", ");
                  show_money(MIE4);
                  printf(", ");
                  show_money(MIE5);
               }  /* ends if MIE values */
               else
                  not_done = 0;
            }  /* ends M&IE loop */
            break;

         case 4:
            printf("\nActual Lodging:");
            t->actual_lodging = get_money();
            break;
      
         case 5:
            printf("\nPOV Miles:");
            gets(s);
            t->pov_miles = atoi(s);
            break;

         case 6:
            printf("\nDesc:");
            gets(t->pov_desc);
            break;

         case 7:
            printf("\nRental Car:");
            t->rental_car = get_money();
            break;

         case 8:
            printf("\nDesc:");
            gets(t->rental_car_desc);
            break;

         case 9:
            printf("\nTaxi:");
            t->taxi = get_money();
            break;

         case 10:
            printf("\nDesc:");
            gets(t->taxi_desc);
            break;

         case 11:
            printf("\nParking:");
            t->parking = get_money();
            break;
      
         case 12:
            printf("\nDesc:");
            gets(t->parking_desc);
            break;
      
         case 13:
            printf("\nOfficial Phone:");
            t->phone = get_money();
            break;
      
         case 14:
            printf("\nDesc:");
            gets(t->phone_desc);
            break;

         case 15:
            printf("\nOther:");
            t->other = get_money();
            break;

         case 16:
            printf("\nDesc:");
            gets(t->other_desc);
            break;

         case 17:
            if(t->next == END_OF_LIST){
               printf("\nNo more daily expenses");
               not_finished = 0;
            }  /* ends if END_OF_LIST */
            else
               t = t->next;
            break;

         case 18:
            not_finished = 0;
            break;

         default:
            printf("\n\nSorry, cannot understand your");
            printf(" choice, try again.");
            break;

      }  /* ends switch choice */
   }  /* ends while not_finished */
}  /* ends edit_daily_expenses */
/*****************************************************/
/*****************************************************/
/*PAGE edit_rental_expenses

   This function allows the user to edit the
   rental car personal use information.
*/

edit_rental_expenses(rs)
   struct rental_struct *rs;
{
   char r[L], s[L];
   int  choice, not_finished = 1;
   long temp;

   while(not_finished){
      printf("\n\t1. Personal mileage is %ld", 
             rs->personal_mileage);
      printf("\n\t2. Total mileage is %ld",
             rs->total_mileage);
      printf("\n\t3. Total gas is $%8.2f",
             dollars_of(rs->total_gas));
      printf("\n\n\tEnter number to make a change, 0 to quit");
      printf("\n\t");
      gets(r);
      choice = atoi(r);
      switch(choice){

         case 0:
            not_finished = 0;
            break;

         case 1:
            printf("\nPersonal Mileage:");
            gets(s);
            rs->personal_mileage = atoi(s);
            break;

         case 2:
            printf("\nTotal Rental Car Mileage:");
            printf("");
            gets(s);
            rs->total_mileage = atoi(s);
            break;

         case 3:
            printf("\nTotal Gas:$");
            temp = get_money();
            rs->total_gas = temp;
            break;

         default:
            printf("\n\nSorry, cannot understand your ");
            printf("choice, try again.");
            break;
      }  /* ends switch choice */
   }  /* ends while not_finished */
}  /* ends edit_rental_expenses */
/*****************************************************/
/*****************************************************/
/*PAGE show_main_menu

   This function shows the main menu on
   the screen.
*/

show_main_menu()
{
   printf("\n");
   printf("\n\tTravel Accounting System - CAC - ");
   printf("Version 1.5 - April 1994");
   printf("\n");
   printf("\n1. Process new accounting");
   printf("\n2. Review or print old accounting");
   printf("\n");
   printf("\n   Enter 0 to quit");
   printf("\n\n");
}  /* ends show_main_menu */
/*****************************************************/
/*PAGE show_review_menu

   This function shows the review menu on
   the screen.
*/

show_review_menu()
{
   printf("\n");
   printf("\nDo you want to review or change:");
   printf("\n\t1. Traveller's name and ORN");
   printf("\n\t2. Cash advance");
   printf("\n\t3. GTR or Ticket advance amount");
   printf("\n\t4. Transportation costs ");
   printf("\n\t5. Itinerary");
   printf("\n\t6. Daily expenses");
   printf("\n\t7. Rental Car Personal Use");
   printf("\n\t\tEnter 0 to quit");
   printf("\n\n");
}  /* ends show_review_menu */
/*****************************************************/
/*****************************************************/
/*PAGE get_mdy

   Interact with the user to get the 
   month-day-year structure.
*/

get_mdy(a)
   struct MDY_struct *a;
{
   char r[L];

   printf("\nEnter month number:");
   gets(r);
   a->month = atoi(r);
   if(a->month != -1){
      printf("Enter day number:");
      gets(r);
      a->day = atoi(r); 
      printf("Enter year number (two digit):");
      gets(r);
      a->year = atoi(r);
   }
}  /* ends get_mdy */
/*****************************************************/
/*****************************************************/
/*PAGE get_name

   Interact with the user to get the 
   name of the traveller.
*/

get_name(a)
   char a[];
{
   int i;
   printf("\n\t\tName:");
   gets(a);
}  /* ends get_name */
/*****************************************************/
/*****************************************************/
/*PAGE get_data_file_name

        Use the name of the traveller and the
        date to create a file name for the
        data file.

        If you are using a DOS system, the user
        will enter the file name by hand.
*/

get_data_file_name(name, date_string, file_name)
   char date_string[], file_name[], name[];
{
   char   s[L], s2[L];
   FILE   *fp;
   int    i, j, k, looking;

   s2[0] = '\0';

#ifdef UNIX_SYSTEM
        /* find first non-blank character in the name */
      i=0;
      while(name[i] == ' ')
         i++;

         /* copy non-blank characters from name */
      j=0;
      while(name[i] != '\0' &&
            name[i] != '\n'){
         if(name[i] == ' ')
            file_name[j] = '.';
         else
            file_name[j] = name[i];
         j++;
         i++;
      }
   
         /* remove any extra periods */
      while(file_name[j-1] == '.')
         j--;
      file_name[j++] = '.';
      file_name[j]   = '\0';
   
      strcat(file_name, date_string);
   
      looking      = 1;
      k            = 0; 
      strcpy(s2, file_name);
   
      while(looking){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -