/* Copyright (c) 2004 by Greg Lehey. * * This software is distributed under the so-called ``Berkeley * License'': * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * This software is provided ``as is'', and any express or implied * warranties, including, but not limited to, the implied warranties of * merchantability and fitness for a particular purpose are disclaimed. * In no event shall the company or contributors be liable for any * direct, indirect, incidental, special, exemplary, or consequential * damages (including, but not limited to, procurement of substitute * goods or services; loss of use, data, or profits; or business * interruption) however caused and on any theory of liability, whether * in contract, strict liability, or tort (including negligence or * otherwise) arising in any way out of the use of this software, even if * advised of the possibility of such damage. * * $Id: abv.c,v 1.4 2004/01/23 03:04:00 grog Exp $ */ /* * Print a table of alcohol by volume or by weight against initial and * final gravities. */ #include #include #include #include #include #include #include #include #include #include #include #include "beer.h" double max_og = 1.100; double og_step = 0.002; double max_fg = 1.020; double fg_step = 0.001; int main (int argc, char *argv []) { double OG; double FG; if (argc > 1) { fprintf (stderr, "No arguments, please\n"); return 1; } printf ("The following table lists the values for three different\n" "calculations of alcohol by volume based on different\n" "formulae. The first is calculated by the function\n" "alcohol_by_weight_fix() from Domenick Venezia's library\n" "functions. The second is caculated by the function\n" "alcohol_by_weight_AJ() from the same library. The third is\n" "the simple formula (SG - FG) x 133 proposed on the Oz\n" "Craftbrewing list by Geoff Saunders \n\n"); printf ("OG\tFG...\n\n\t"); for (FG = 1.000; FG < max_fg; FG += fg_step) printf ("%6.4f\t", FG); printf ("\n"); for (OG = 1.000; OG < max_og; OG += og_step) { printf ("%6.4f\t", OG); for (FG = 1.000; (FG < OG) && (FG < max_fg); FG += fg_step) printf ("%6.4f\t", abw_to_abv (alcohol_by_weight_fix (OG, FG)) ); printf ("\n"); printf ("%6.4f\t", OG); for (FG = 1.000; (FG < OG) && (FG < max_fg); FG += fg_step) printf ("%6.4f\t", abw_to_abv (alcohol_by_weight_AJ (OG, FG)) ); printf ("\n"); printf ("%6.4f\t", OG); for (FG = 1.000; (FG < OG) && (FG < max_fg); FG += fg_step) printf ("%6.4f\t", (OG - FG) * 133); printf ("\n"); printf ("\n"); } return 0; }