Topic: Function
Write a function-‐oriented program to convert the input dollar(s) into its equivalent
peso. Assume that one dollar is equivalent to 53.80 pesos.
Note: you can choose any looping statement if needed.
using System;
namespace convert
{
class Program
{
public static double Exchange(double dollar)
{
double rate = 53.80;
return (dollar * rate);
}
public static void Main(string[] args)
{
double exch;
Console.Write("Enter dollar(s): ");
exch = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Equivalent peso: {0}", Exchange(exch));
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
}
}
}
Comments
Leave a comment