1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
namespace RITCS { /// <summary> /// This program produces a conversion table from Celsius to /// Fahrenheit for values from 0 to 99. This program appears in /// "C# y" by Kutay Zorlu /// /// <list type="bullet"> /// /// <item> /// <term>Author</term> /// <description>Kutay ZORLU</description> /// </item> /// /// /// <item> /// <term>Author</term> /// <description>Test user</description> /// </item> /// /// </list> /// /// </summary> class ConversionTable { const int COLS_PER_LINE = 5; // number of temp. cols const int MAX_LINE_NO = 20; // number of rows of temp. const string GAP = "\t"; // white space between cols /// <summary> /// The main program. /// </summary> /// <param name="args">command line arguments (ignored)</param> public static void Main( string [] args ){ // print out the table heading Console.WriteLine( "\t\tTemperature Conversion Table" ); Console.WriteLine( "\t\t============================" ); Console.WriteLine(); // print a heading for each column of output for ( int col = 0; col < COLS_PER_LINE; col++ ){ Console.Write( "C F" + GAP ); } Console.WriteLine(); // print out the lines of the table for ( int row = 0; row < MAX_LINE_NO; row++ ){ printRow( row ); } Console.WriteLine(); } /// <summary> /// Convert degrees Celsius to degrees Fahrenheit /// </summary> /// <param name="celsius">degrees in Celsius</param> /// <returns>degrees in Fahrenheit</returns> static int fahrenheit( int celsius ) { return (int)Math.Round( (double)(celsius * 9 / 5 + 32) ); } } // ConversionTable } |