Jump to content

C# Convert Celsius to Fahrenheit

- - - - -

  • Please log in to reply
No replies to this topic

#1
QuackWare

QuackWare

    Learning Programmer

  • Members
  • PipPipPip
  • 95 posts
C# Convert Celsius to Fahrenheit

 /** This code snippet was taken from freecodesnippets.com*/


using System;


public class PassArguments {

  public static void Main(String[] args) {

    double  hotC, coldC;

    double  hotF, coldF; 

    if (args.Length != 2) {

      Console.WriteLine ("Enter a hot and a cold temerature as program arguments.");

      return;

    }       

    hotC = double.Parse(args[0]); 

    hotF = 9.0*hotC/5.0 + 32.0;  

    Console.WriteLine ("The Fahrenheit temperature is: {0:F1}", hotF);

    coldC = double.Parse(args[1]); 

    coldF = 9.0*coldC/5.0 + 32.0;

    Console.WriteLine ("The Fahrenheit temperature is: {0:F1}", coldF);

  }

}





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users