*/
Stuck? Need help? Ask questions on our forums.
*/

View \ENTYPES.PAS

This is the second disk of the PASCAL TUTOR system. It has the

Submitted By: WEBMASTER
Rating: (Not rated) (Rate It)


(* Chapter 8 - Program 1 *)
program Enumerated_Types;

type Days = (Mon,Tue,Wed,Thu,Fri,Sat,Sun);
     Time_Of_Day = (Morning,Afternoon,Evening,Night);

var  Day              : Days;
     Time             : Time_Of_Day;
     Regular_Rate     : real;
     Evening_Premium  : real;
     Night_Premium    : real;
     Weekend_Premium  : real;
     Total_Pay        : real;

begin  (* main program *)
   Writeln('Pay rate table':33);
   Writeln;
   Write('  DAY        Morning  Afternoon');
   Writeln('  Evening    Night');
   Writeln;

   Regular_Rate := 12.00;     (* This is the normal pay rate *)
   Evening_Premium := 1.10;   (* 10 percent extra for working late *)
   Night_Premium := 1.33;     (* 33 percent extra for graveyard *)
   Weekend_Premium := 1.25;   (* 25 percent extra for weekends *)

   for Day := Mon to Sun do begin
      case Day of
        Mon : Write('Monday   ');
        Tue : Write('Tuesday  ');
        Wed : Write('Wednesday');
        Thu : Write('Thursday ');
        Fri : Write('Friday   ');
        Sat : Write('Saturday ');
        Sun : Write('Sunday   ');
      end(* of case statement *)

      for Time := Morning to Night do begin
         case Time of
           Morning   : Total_Pay := Regular_Rate;
           Afternoon : Total_Pay := Regular_Rate;
           Evening   : Total_Pay := Regular_Rate * Evening_Premium;
           Night     : Total_Pay := Regular_Rate * Night_Premium;
         end(* of case statement *)

         case Day of
           Sat : Total_Pay := Total_Pay * Weekend_Premium;
           Sun : Total_Pay := Total_Pay * Weekend_Premium;
         end(* of case statement *)

         Write(Total_Pay:10:2);
      end(* of "for Time" loop *)
      Writeln;
   end; (* of "for Day" loop *)
end(* of main program *)

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.