c# problem pls help - Sajha Mobile
SAJHA MOBILE
c# problem pls help
Posts 2 · Viewed 4625 · Go to Last Post
redlotus
· Snapshot
Like · Likedby · 0
Develop a C# console application using four overloaded methods that will return the difference of two parameters in each case. Your methods should contain the logic to return the difference of the larger parameter – smaller parameter, regardless of parameter order. Be sure to test all four methods using different sets of input to ensure that the correct results are returned.

Parm 1 Type

Parm 2 Type

Return Type

int

int

Int

double

double

double

int

double

double

double

int

double

The output might look similar to this:

The difference of 30 and 34 is: 4
The difference of 27.35 and 37.70 is: 10.35
The difference of 31 and 37.40 is: 6.4
The difference of 24.28 and 34 is: 9.72
Press any key to continue . . .

DeltaGamma
· Snapshot
Like · Liked by · 0

Hi Red, here is solution add some more codes.


 


using System;


public class Exercise


{


// first


static int first(int a, int b)


{


return a - b ;


}


// second


static double second(double x, double y)


{


return x - y;


}


static int Main()


{


int a, b;


double x, y;


Console.WriteLine("Enter int, int only");


Console.Write("a: ");


a = int.Parse(Console.ReadLine());


Console.Write("b: ");


b = int.Parse(Console.ReadLine());


Console.WriteLine("\nint result " +


"regard : ");


Console.WriteLine("Int = {0}mm", first(a, b));


Console.WriteLine();


Console.WriteLine("Enter double, double only");


Console.Write("x: ");


x = double.Parse(Console.ReadLine());


Console.Write("y: ");


y = double.Parse(Console.ReadLine());


Console.WriteLine("\ndouble result " +


"regard : ");


Console.WriteLine("double = {0}mm",


second(x, y));


Console.WriteLine();


return 0;


}


}


Delta

Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 18 · Viewed 4060 · Likes 3
· Posts 1 · Viewed 102
· Posts 1 · Viewed 97
· Posts 1 · Viewed 189
· Posts 1 · Viewed 399
· Posts 1 · Viewed 233
· Posts 1 · Viewed 139
· Posts 1 · Viewed 118
· Posts 77 · Viewed 18826 · Likes 18
· Posts 1 · Viewed 168



Your Banner Here
Travel Partners
Travel House Nepal