Monday, April 6, 2020

SSTAX.P

[Table of Contents]
Disk Image

SSTAX.P is a sample program from the Decision Making section of the Kyan Pascal 2.x manual/tutorial. It shows how to use IF/THEN statements to make decisions, how to prompt for information from the user, how to receive information from the user, how to calculate results using formulas, and finally, show the results.

What's on the disk?


The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files (none of which are used in this program), Kyan Pascal Run-time library, and ...

SSTAX.P - Source code file
P.OUT - Kyan Pascal intermediate file
SSTAX - Executable file

Source Code


(* SSTAX.P *)
(* Kyan Pascal 2.04 / Atari 8-bit *)

PROGRAM SSTAX (Input, Output);

CONST
   TaxRate=0.075;
   TaxMaximum=4275.0;

VAR (* These values will be entered by the user *)
   Hours, Rate, TaxNow, TaxToDate: Real;

BEGIN (* The BODY of the program *)
(* Get hours, rate, and tax-to-date values *)
   Write(Chr(125));
   Writeln;
   Writeln;
   Write('Hours worked=');
   Readln(Hours);
   Write('Hourly rate=$');
   Readln(Rate);
   Write('Soc Sec Tax paid-to-date=$');
   Readln(TaxToDate);

   (* Compute Soc Sec Tax for this pay period *)

   TaxNow:=Hours*Rate*TaxRate;

   (* Determine if Tax paid-to-date + tax for this pay
      period is greater than the maximum tax allowable *)

   IF TaxToDate + TaxNow > TaxMaximum THEN
      BEGIN
         TaxNow:=TaxMaximum-TaxToDate;
         TaxToDate:=TaxMaximum
      END (* of the IF-TRUE statement *)
   ELSE (* if the IF statement is false *)
      TaxToDate:=TaxNow+TaxToDate;

   (* Write Results *)
   Writeln('Soc Sec Tax This Pay Period=$',TaxNow:8:2);
   Writeln('Soc Sec Tax To Date=$',TaxToDate:8:2)
END.


Sample Run



No comments:

Post a Comment