/************************************************************************/
/* TaxSolve_NY_IT-201_2005.c - NY State Tax form IT-201 for 2005.	*/
/* Copyright (C) 2003, 2005 - Aston Roberts, Skeet Monker		*/
/* 									*/
/* Compile:   gcc taxsolve_NY_IT201_2005.c -o taxsolve_NY_IT201_2005	*/
/* Run:	      ./taxsolve_NY_IT201_2005  NY_IT201_2005.dat 		*/
/* 									*/
/* GNU Public License - GPL:						*/
/* This program is free software; you can redistribute it and/or	*/
/* modify it under the terms of the GNU General Public License as	*/
/* published by the Free Software Foundation; either version 2 of the	*/
/* License, or (at your option) any later version.			*/
/* 									*/
/* This program is distributed in the hope that it will be useful,	*/
/* but WITHOUT ANY WARRANTY; without even the implied warranty of	*/
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU	*/
/* General Public License for more details.				*/
/* 									*/
/* You should have received a copy of the GNU General Public License	*/
/* along with this program; if not, write to the Free Software		*/
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA		*/
/* 02111-1307 USA							*/
/* 									*/
/* Aston Roberts 4-8-2003	aston_roberts@yahoo.com			*/
/* Modified for NY 2003 taxes - Skeet Monker				*/
/* Modified for NY 2004 taxes - A Roberts				*/
/* Modified for NY 2005 taxes - Skeet Monker				*/
/************************************************************************/

#include <stdio.h>
#include <time.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>

float thisversion=3.0;

#include "taxsolve_routines.c"

float A[10], S[10];

#define SINGLE                  1
#define MARRIED_FILLING_JOINTLY 2
#define MARRIED_FILLING_SEPARAT 3
#define HEAD_OF_HOUSEHOLD       4
#define WIDOW                   5
#define Yes 1
#define No  0


float TaxRateFunction( float income, int status )
{
 float tax;

 switch (status)
  {
   case MARRIED_FILLING_JOINTLY: case WIDOW:
	if (income<= 16000.0) tax = 0.04 * income; else
	if (income<= 22000.0) tax = 640.0 + 0.045  * (income - 16000.0); else
	if (income<= 26000.0) tax = 910.0 + 0.0525 * (income - 22000.0); else
	if (income<= 40000.0) tax = 1120.0 + 0.059 * (income - 26000.0); else
	if (income<=150000.0) tax = 1946.0 + 0.0685 * (income - 40000.0); else
	if (income<=500000.0) tax = 9481.0 + 0.07375 * (income - 150000.0); else
	tax = 35294.0 + 0.077 * (income - 500000.0); 
      break;
   case SINGLE: case MARRIED_FILLING_SEPARAT:
	if (income<=  8000.0) tax =  	     0.04   * income; else
	if (income<= 11000.0) tax =  320.0 + 0.045  * (income - 8000.0); else
	if (income<= 13000.0) tax =  455.0 + 0.0525 * (income - 11000.0); else
	if (income<= 20000.0) tax =  560.0 + 0.059  * (income - 13000.0); else
	if (income<=100000.0) tax =  973.0 + 0.0685 * (income - 20000.0); else
	if (income<=500000.0) tax = 6453.0 + 0.07375 * (income - 100000.0); else
	tax = 35953.0 + 0.077 * (income - 500000.0); 
      break;
   case HEAD_OF_HOUSEHOLD:
	if (income<= 11000.0) tax = 0.04 * income; else
	if (income<= 15000.0) tax = 440.0 + 0.045  * (income - 11000.0); else
	if (income<= 17000.0) tax = 620.0 + 0.0525 * (income - 15000.0); else
	if (income<= 30000.0) tax = 725.0 + 0.059  * (income - 17000.0); else
	if (income<=125000.0) tax = 1492.0 + 0.0685 * (income - 30000.0); else
	if (income<=500000.0) tax = 8000.0 + 0.07375 * (income - 125000.0); else
	tax = 35656.0 + 0.077 * (income - 500000.0); 
      break;
   default: printf("Error: Unhandled status\n"); exit(0); break;
  }
 return tax;
}


float TaxRateLookup( float income, int status )
{
 float tax, dx;
 int m;

 if (income<25.0) dx = 12.5; else
 if (income<50.0) dx = 25.0; else dx = 50.0;

 /* Round and truncate results from tax-function to approximate table lookup. */
 m = income / dx;             /* Round income to nearest $50. */
 income = (float)m * dx + 0.5 * dx;      /* Place into center of a $50 bracket. */
 tax = TaxRateFunction( income, status );

 return (int)(tax + 0.5);
}


float NYcityTaxRateFunction( float income, int status )
{
 float tax, dx;
 int m;

 if (income<25.0) dx = 12.5; else
 if (income<50.0) dx = 25.0; else dx = 50.0;

 m = income / dx;             /* Round income to nearest $50. */
 if (income<65000.0)
  income = m * dx + 0.5 * dx;      /* Place into center of a $50 bracket. */

 if ((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT))
  {
   if (income < 8000.0) tax = income * 0.04; else
   if (income < 11000.0) tax = (income - 8000.00) * 0.045 + 320.0; else
   if (income < 13000.0) tax = (income - 11000.00) * 0.0525 + 455.0; else
   if (income < 20000.0) tax = (income - 13000.00) * 0.059 + 560.0; else
   if (income < 100000.0) tax = (income - 20000.00) * 0.0685 + 973.0; else
   if (income < 500000.0) tax = (income - 100000.00) * 0.0725 + 6453.0; else
   tax = (income - 500000.00) * 0.077 + 35453.0;
  }
 else
 if ((status==MARRIED_FILLING_JOINTLY) || (status==WIDOW))
  {
   if (income < 16000.0)  tax = income * 0.04; else
   if (income < 22000.0)  tax = (income - 16000.00) * 0.045 + 640.00; else
   if (income < 26000.0)  tax = (income - 22000.00) * 0.0525 + 910.0; else
   if (income < 40000.0)  tax = (income - 26000.00) * 0.059 + 1120.0; else
   if (income < 150000.0) tax = (income - 40000.00) * 0.0685 + 1946.0; else
   if (income < 500000.0) tax = (income - 150000.00) * 0.0725 + 9481.0; else
   tax = (income - 500000.00) * 0.077 + 34856.0;
  }
 else
 if (status==HEAD_OF_HOUSEHOLD) 
  {
   if (income < 11000.00) tax = income * 0.04; else
   if (income < 15000.00) tax = (income - 11000.00) * 0.045 + 440.0; else
   if (income < 17000.00) tax = (income - 15000.00) * 0.0525 + 620.0; else
   if (income < 30000.00) tax = (income - 17000.00) * 0.059 + 725.0; else
   if (income < 125000.0) tax = (income - 30000.00) * 0.0685 + 1492.0; else
   if (income < 500000.0) tax = (income - 125000.00) * 0.0725 + 8000.0; else
   tax = (income - 500000.00) * 0.077 + 35187.0;
 }
 else {printf("Status not covered.\n"); exit(0);}

 if (income<65000.0) tax = (int)(tax + 0.5);   /* Round result to whole dollar. */
 return tax;
}




/*----------------------------------------------------------------------------*/

int main( int argc, char *argv[] )
{
 int i, j, k;
 char word[1000], outfname[1000];
 int status=0;
 time_t now;
 int Dependent, Exemptions, nyc_resident;
 float itemized_ded, std_ded=0.0, WS[50];

 /* Intercept any command-line arguments. */
 printf("NY-IT201 - v%3.1f\n", thisversion);
 i = 1;  k=1;
 while (i < argc)
 {
  if (strcmp(argv[i],"-verbose")==0)  verbose = 1;
  else
  if (k==1)
   {
    infile = fopen(argv[i],"r");
    if (infile==0) {printf("ERROR: Parameter file '%s' could not be opened.\n", argv[i]); exit(1);}
    k = 2;
    /* Base name of output file on input file. */
    strcpy(outfname,argv[i]);
    j = strlen(outfname)-1;
    while ((j>=0) && (outfname[j]!='.')) j--;
    if (j<0) strcat(outfname,".out"); else strcpy(&(outfname[j]),".out");
    outfile = fopen(outfname,"w");
    if (outfile==0) {printf("ERROR: Output file '%s' could not be opened.\n", outfname); exit(1);}
    printf("Writing results to file:  %s\n", outfname);
   }
  else {printf("Unknown command-line parameter '%s'\n", argv[i]); exit(1);}
  i = i + 1;
 }

 if (infile==0) {printf("Error: No input file on command line.\n"); exit(1);}

 /* Pre-initialize all lines to zeros. */
 for (i=0; i<MAX_LINES; i++) L[i] = 0.0;

 /* Accept parameters from input file. */
 /* Expect  NY IT200 form lines, something like:
	Title:  NY IT-200 1999 Return
	L14		{Wages}
	L15a		{Interest}
	L16		{Dividends}
	L18		{Capital Gains}
	S1		{Property Tax}
	L42		{Witheld tax, from W-2}
*/


 /* Accept Form's "Title" line, and put out with date-stamp for records. */
 read_line( infile, word );
 now = time(0);
 fprintf(outfile,"\n%s		%s\n", word, ctime( &now ));

 /* get_parameter(infile, kind, x, emssg ) */
 get_parameter( infile, 's', word, "Status" );
 get_parameter( infile, 'l', word, "Status?");
 if (strncasecmp(word,"Single",4)==0) status = SINGLE; else
 if (strncasecmp(word,"Married/Joint",13)==0) status = MARRIED_FILLING_JOINTLY; else
 if (strncasecmp(word,"Married/Sep",11)==0) status = MARRIED_FILLING_SEPARAT; else
 if (strncasecmp(word,"Head_of_House",4)==0) status = HEAD_OF_HOUSEHOLD; else
 if (strncasecmp(word,"Widow",4)==0) status = WIDOW;
 else { printf("Error: unrecognized status '%s'. Exiting.\n", word); exit(0); }
 fprintf(outfile,"Status = %s (%d)\n", word, status);

 get_parameter( infile, 's', word, "Dependent" );
 get_parameter( infile, 'b', &Dependent, "Dependent?"); 
 if (Dependent==1) fprintf(outfile," Check box C = Yes\n");  else fprintf(outfile," Check box C = No\n");

 GetLineF( "L1", &L[1] );	/* Wages. */

 GetLineF( "L2", &L[2] );	/* Taxable Interest. */

 GetLineF( "L3", &L[3] );	/* Dividends. */

 GetLineF( "L4", &L[4] );	/* Taxable refunds, credits, offsets */

 GetLineF( "L5", &L[5] );	/* Alimony received */

 GetLineF( "L6", &L[6] );	/* Business income/loss (fed sched C) */

 GetLineF( "L7", &L[7] );	/* Capital gains/losses (fed sched D) */

 GetLineF( "L8", &L[8] );	/* Other gains/losses (fed form 4794) */

 GetLineF( "L9", &L[9] );	/* Taxable IRA distributions */

 GetLineF( "L10", &L[10] );	/* Taxable pension/annuity amounts  */

 GetLineF( "L11", &L[11] );	/* Rental, royalties, partnership, S corp, (fed sched E) */

 GetLineF( "L12", &L[12] );	/* Farm income (fed sched F) */

 GetLineF( "L13", &L[13] );	/* Unemployment compensation */

 GetLineF( "L14", &L[14] );	/* Taxable Social Sec. benefits */
 L[27] = L[14];

 GetLineF( "L15", &L[15] );	/* Other income (pg. 80) */

 for (j=1; j<=15; j++) L[16] = L[16] + L[j];
 showline(16);

 GetLineF( "L17", &L[17] );	/* Total federal adjustments to income (pg 20) */

 L[18] = L[16] - L[17];
 showline_wmsg(18,"federal adjusted gross income");
 
 L[19] = L[18];

 GetLineF( "L20", &L[20] );	/* Interest income from non-NY state or local bonds */

 GetLineF( "L21", &L[21] );	/* Public employee retirement contributions (pg 82) */

 GetLineF( "L22", &L[22] );	/* College choice tuition saving distributions */

 GetLineF( "L23", &L[23] );	/* Other (pg 83) */

 for (j=19; j<=23; j++) L[24] = L[24] + L[j];
 showline(24);

 L[25] = L[4];			/* Taxable refunds, credits, offsets */
 showline(25);

 GetLineF( "L26", &L[26] );	/* Pensions of NYS and local governments and the federal government (see page 24)  */

 L[27] = L[14];			/* Taxable amount of social security benefits */
 showline(27);

 GetLineF( "L28", &L[28] );	/* Interest income on U.S. government bonds */

 GetLineF( "L29", &L[29] );	/* Pension and annuity income exclusion  */

 GetLineF( "L30", &L[30] );	/* College choice tuition savings deduction / earnings distributions */

 GetLineF( "L31", &L[31] );	/* Other (see page 87) */

 for (j=25; j<=31; j++) L[32] = L[32] + L[j];
 showline(32);

 L[33] = L[24] - L[32];
 showline_wmsg(33,"New York adjusted gross income (AGI)");

 GetLine( "Itemized_Deduction", &itemized_ded );     /* Form IT-201-ATT or 0.0 if std ded. */
 switch (status)
  {
   case SINGLE: if (Dependent)   std_ded = 3000.0; else std_ded = 7500.0; break;
   case MARRIED_FILLING_JOINTLY: std_ded = 14600.0; break;
   case MARRIED_FILLING_SEPARAT: std_ded =  6500.0; break;
   case HEAD_OF_HOUSEHOLD: 	 std_ded = 10500.0; break;
   case WIDOW: 			 std_ded = 14600.0; break;
  }
 if (std_ded > itemized_ded) 
  {
   L[34] = std_ded; 
   showline_wmsg(34,"(Mark std-ded)");
  }
 else
  {
   L[34] = itemized_ded;
   showline_wmsg(34,"(Mark itemized-ded)");
  }

 L[35] = L[33] - L[34];
 if (L[35]<0.0) L[35] = 0.0;
 else showline(35);

 get_parameter( infile, 's', word, "L36" );	/* Number of Dependent Exemptions (Pg 95, line e) */
 get_parameters( infile, 'i', &k, "L36" );
 L[36] = 1000.0 * (float)k;
 showline(36);
 
 L[37] = L[35] - L[36];
 if (L[37]<0.0) L[37] = 0.0;
 else showline_wmsg(37,"taxable income");

 L[38] = L[37];
 showline(37);

 if (L[33]<=100000.0)
  {
   if (L[38]<65000.0)
    L[39] = TaxRateLookup( L[38], status );
   else
    L[39] = TaxRateFunction( L[38], status );
  }
 else 
 if (L[33]<=150000.0)
  {
   if ((status==MARRIED_FILLING_JOINTLY) || (status==WIDOW) || 
	(((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT)) && (L[38]<=100000.0)) ||
	((status==HEAD_OF_HOUSEHOLD) && (L[38]<=125000)))
    { /*WS1*/
      WS[1] = L[33];	WS[2] = L[38];	WS[3] = 0.0685 * WS[2];
      WS[4] = TaxRateFunction( L[38], status );
      WS[5] = WS[3] - WS[4];	
      WS[6] = smallerof( WS[1] - 100000.0, 50000.0 );
      WS[7] = WS[6] / 50000.0;   j = 10000.0 * WS[7] + 0.5;   WS[7] = 0.0001 * (float)j;
      WS[8] = WS[5] * WS[7];
      WS[9] = WS[4] + WS[8];
      L[39] = WS[9];
    } /*WS1*/
   else
    { /*WS2*/
      WS[1] = L[33];	WS[2] = L[38];
      WS[3] = TaxRateFunction( L[38], status );
      if ((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT)) WS[4] = 397.0;  else  WS[4] = 563.0;
      WS[5] = smallerof( WS[1] - 100000.0, 50000.0 );
      WS[6] = WS[5] / 50000.0;   j = 10000.0 * WS[6] + 0.5;   WS[6] = 0.0001 * (float)j;
      WS[7] = WS[4] * WS[6];
      WS[8] = WS[3] + WS[7];
      L[39] = WS[8];
    } /*WS2*/
  }
 else
 if (L[33]<=500000.0)
  {
   if (((status==MARRIED_FILLING_JOINTLY) && (L[38]<=150000.0)) || 
	((status==WIDOW) && (L[38]<=150000.0)) || 
	(((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT)) && (L[38]<=100000.0)) ||
	((status==HEAD_OF_HOUSEHOLD) && (L[38]<=125000)))
    { /*WS3*/
      WS[1] = L[38]; 
      WS[2] = 0.0685 * WS[1]; 
      L[39] = WS[2];
    } /*WS3*/
   else
    { /*WS4*/
      WS[1] = L[33];	WS[2] = L[38];	WS[3] = 0.0725 * WS[2];
      WS[4] = TaxRateFunction( WS[2], status );
      WS[5] = WS[3] - WS[4];
      if ((status==MARRIED_FILLING_JOINTLY) || (status==WIDOW)) WS[6] = 794.0;  else  
      if ((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT)) WS[6] = 397.0;  else  WS[6] = 563.0;
      WS[7] = WS[5] - WS[6];
      WS[8] = WS[1] - 150000.0;  if (WS[8] > 50000.0) WS[8] = 50000.0;
      WS[9] = WS[8] / 50000.0;   j = 10000.0 * WS[9] + 0.5;   WS[9] = 0.0001 * (float)j;
      WS[10] = WS[7] * WS[9];
      WS[11] = WS[6];
      WS[12] = WS[4] + WS[10] + WS[11];
      L[39] = WS[12];
    } /*WS4*/
  }
 else
  { /*WS5*/  /* L[33] > 500,000 */
   WS[1] = L[38];
   WS[2] = 0.077 * WS[1];
   L[39] = WS[2];
  } /*WS5*/
 showline(39);

 /* Household credit. */
 get_parameter( infile, 's', word, "Exemptions" );	/* NY dependent exemptions, Pg 96 Line C. */
 get_parameter( infile, 'i', &Exemptions, "Exemptions" );
 if (Dependent) L[40] = 0.0;
 else
 if (status==SINGLE)
  {
   if (L[18] <  5000.0) L[40] = 75.0; else
   if (L[18] <  6000.0) L[40] = 60.0; else
   if (L[18] <  7000.0) L[40] = 50.0; else
   if (L[18] < 20000.0) L[40] = 45.0; else
   if (L[18] < 25000.0) L[40] = 45.0; else
   if (L[18] < 28000.0) L[40] = 20.0; else  L[40] = 0.0;
  }
 else	/* Status = MARRIED_FILLING_JOINTLY, MARRIED_FILLING_SEPARAT, Head_of_house, Widow */
  if (status!=MARRIED_FILLING_SEPARAT)
   {
    if (L[18] <  5000.0) L[40] = 90.0 + 15.0 * (Exemptions-1); else
    if (L[18] <  6000.0) L[40] = 75.0 + 15.0 * (Exemptions-1); else
    if (L[18] <  7000.0) L[40] = 65.0 + 15.0 * (Exemptions-1); else
    if (L[18] < 20000.0) L[40] = 60.0 + 15.0 * (Exemptions-1); else
    if (L[18] < 22000.0) L[40] = 60.0 + 10.0 * (Exemptions-1); else
    if (L[18] < 25000.0) L[40] = 50.0 + 10.0 * (Exemptions-1); else
    if (L[18] < 28000.0) L[40] = 40.0 +  5.0 * (Exemptions-1); else  
    if (L[18] < 32000.0) L[40] = 20.0 +  5.0 * (Exemptions-1); else  L[40] = 0.0;
   }
  else
   {
    if (L[18] <  5000.0) L[40] = 45.0 + 7.5 * (Exemptions-1); else
    if (L[18] <  6000.0) L[40] = 37.5 + 7.5 * (Exemptions-1); else
    if (L[18] <  7000.0) L[40] = 32.5 + 7.5 * (Exemptions-1); else
    if (L[18] < 20000.0) L[40] = 30.0 + 7.5 * (Exemptions-1); else
    if (L[18] < 22000.0) L[40] = 30.0 + 5.0 * (Exemptions-1); else
    if (L[18] < 25000.0) L[40] = 25.0 + 5.0 * (Exemptions-1); else
    if (L[18] < 28000.0) L[40] = 20.0 + 2.5 * (Exemptions-1); else  
    if (L[18] < 32000.0) L[40] = 10.0 + 2.5 * (Exemptions-1); else  L[40] = 0.0;
   }
 showline_wmsg(40,"NY state household credit");	/* NY state household credit, (pg 32). */

 GetLineF( "L41", &L[41] );	/* Resident credit, Form IT-112-R or IT-112-C, pg 98 */

 GetLineF( "L42", &L[42] );	/* Other New York State nonrefundable credits  */

 L[43] = L[40] + L[41] + L[42];
 showline_wmsg(43,"New York State Taxes");

 L[44] = L[39] - L[43];
 if (L[44] < 0.0) L[44] = 0.0;
 else showline(44);

 GetLineF( "L45", &L[45] );	/* Net Other New York State taxes, Form IT-201-ATT, line 30 */

 L[46] = L[44] + L[45];
 showline_wmsg(46,"Total New York State taxes");

 get_parameter( infile, 's', word, "NYC_Resident" );
 get_parameter( infile, 'b', &nyc_resident, "NYC_Resident (yes/no) ?"); 

 if (nyc_resident)
  { /*NYC*/
   L[47] = NYcityTaxRateFunction( L[38], status ); 
   showline(47);

   /* NYC Household credit. */
   if (Dependent) L[48] = 0.0;
   else
   if (status==SINGLE)
    {
     if (L[18] <  10000.0) L[48] = 15.0; else
     if (L[18] <  12500.0) L[48] = 10.0; else  L[48] = 0.0;
    }
   else	/* Status = 2, 4, or 5. */
   if (status!=MARRIED_FILLING_SEPARAT)
    {
     if (L[18] <  15000.0) L[48] = 30.0 * Exemptions; else
     if (L[18] <  17500.0) L[48] = 25.0 * Exemptions; else
     if (L[18] <  20000.0) L[48] = 15.0 * Exemptions; else
     if (L[18] <  22500.0) L[48] = 10.0 * Exemptions; else  L[48] = 0.0;
    }
   else
    {
     if (L[18] <  15000.0) L[48] = 15.0 * Exemptions; else
     if (L[18] <  17500.0) L[48] = 12.5 * Exemptions; else
     if (L[18] <  20000.0) L[48] =  7.5 * Exemptions; else
     if (L[18] <  22500.0) L[48] =  5.0 * Exemptions; else  L[48] = 0.0;
    }
   showline_wmsg(48,"NY City household credit");	/* NY City household credit, (pg 34). */

   L[49] = L[47] - L[48];
   if (L[49]>0.0) showline(49);
   else L[49] = 0.0;

   GetLineF( "L50", &L[50] );	/* Part-year New York City resident tax */
   GetLineF( "L51", &L[51] );	/* Other New York City taxes */

   L[52] = L[49] + L[50] + L[51];
   showline(52);

   GetLineF( "L53", &L[53] );	/* NY City nonrefundable credits */

   L[54] = L[52] - L[53];
   if (L[54]>0.0) showline(54);  else  L[54] = 0.0;

   /* Yonkers case not added. */

   L[58] = L[54] + L[55] + L[56] + L[57];
   showline_wmsg(58,"NYC taxes");
  } /*NYC*/

 GetLineF( "L59", &L[59] );	/* Sales or use tax, see pg 65. */

 GetLineF( "L60", &L[60] );	/* Voluntary Gift contibutions (pgs 72, 73, 102). */

 L[61] = L[46] + L[58] + L[59] + L[60];
 showline(61);

 L[62] = L[61];
 showline(61);

 GetLineF( "L63", &L[63] );	/* NY Child care/dependent credit. Form IT-216. */

 GetLineF( "L64", &L[64] );	/* NY Earned income credit. Form IT-213. */

 GetLineF( "L65", &L[65] );	/* Real property credit. Form IT-214. */

 GetLineF( "L66", &L[66] );	/* College tution credit. Form IT-272. */

 if (nyc_resident)		/* City of NY school taxcredit. (pg 103) */
  { /*NYC*/
    if (Dependent) L[67] = 0.0;
    else
    if ((status==SINGLE) || (status==MARRIED_FILLING_SEPARAT) || (status==HEAD_OF_HOUSEHOLD))  L[67] = 62.5;  else
    if ((status==MARRIED_FILLING_JOINTLY) || (status==WIDOW))  L[67] = 125.0;
    showline(67);
    /* L[68] = earned_income_credit; */
    /* showline(68); */
  } /*NYC*/

 GetLineF( "L69", &L[69] );	/* Other refundable credits, IT-201-ATT line 18) */

 GetLineF( "L70", &L[70] );	/* Total NY State tax withheld. */

 GetLineF( "L71", &L[71] );	/* Total City of NY tax withheld. */
 GetLineF( "L72", &L[72] );	/* Yonkers tax withheld. */
 
 GetLineF( "L73", &L[73] );	/* Total estimated tax payments (from IT-370)*/

 for (j=63; j<=73; j++) L[74] = L[74] + L[j];
 showline(74);

 if (L[74] > L[62])
  {
   L[75] = L[74] - L[62];
   fprintf(outfile,"L75 = %6.2f	REFUND !!!\n", L[75] );
   L[76] = L[74];
   showline(76);
  }
 else
  {
   L[78] = L[62] - L[74];
   fprintf(outfile,"L78 = %6.2f	YOU OWE !!!\n", L[78] );
  }
 
 fclose(infile);
 fclose(outfile);
 printf("\nListing results from file: %s\n\n", outfname);
 Display_File( outfname );
 return 0;
}
