{/* 
 * Solution to Problem 1 (Pascal)
 * 11th Annual CS Programming Contest
 * WCU Dept of Math and CS
 * Copyright 2000 , All Rights Reserved
 *
 * Problem Statement:
 * This program prompts the user for a series of purchases;
 * each is either taxable or nontaxable.  The user terminates
 * the input with a sentinel value, and the program totals the
 * purchases and applies the proper sales tax to form a grand total
 * which is shown to the user
 *}

program problem1(input,output);

const
   TAX_RATE =  0.06;
var
   taxable	   : real;
   nontaxable	   : real ;
   currentPurchase : real ;
   currentType	   : char ;
   tax		   : real;
   total	   : real;
begin

   taxable := 0;
   nontaxable := 0;
   currentPurchase := 1; 



   repeat
   begin

      Writeln("Enter a purchase followed by its type: ");
      read(currentPurchase);
      read(currentType);

      write(currentPurchase);
      write(" ");
      writeln(currentType);
 
    if currentType = 't'  then
    begin
       taxable := taxable + currentPurchase;
    end
    else if currentType = 'n' then
    begin
       nontaxable := nontaxable + currentPurchase;
    end
    else
    begin
       Writeln("Bad type: try again.");
    end
   end
   until currentPurchase = 0;
   
   tax := taxable * TAX_RATE;
   
   Write("Taxable total: $");
   writeln(taxable:8:2);
   
   write("Sales tax: $");
   writeln(tax:8:2);
   
   write("Non-taxable total: $");
   writeln(nontaxable:8:2);
   
   write( "Grand Total: $");
   total := taxable + tax + nontaxable;
   writeln(total:8:2);

end.


