Program argument input values: Converts degrees Celsius to degrees Fahrenheit
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);
}
}
Related examples in the same category