Create a method called Distance(double x, double y) The method returns the Eucli
ID: 3816423 • Letter: C
Question
Create a method called Distance(double x, double y) The method returns the Euclidean distance between the two values |x - y| In Main() The user should type the values of x and y Print the value returned by the method DO NOT PUT ANY CONSOLE.ERITELINE STATEMENTS IN THE Distance METHOD in C#Explanation / Answer
using System; using System.Collections.Generic; using System.Text; public double Distance(double x, double y) { if(x>=y) return(x-y); else return(y-x) } namespace Program { class Program { static void Main(string[] args) { double Num1, Num2, result; Console.Write("Enter the First Number : "); Num1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter the Second Number : "); Num2 = Convert.ToInt32(Console.ReadLine()); result=Distance(Num1,Num2); Console.WriteLine("The result is : {0}", result); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.