Write a C# application that asks the user to input the required data to implemen
ID: 3695280 • Letter: W
Question
Write a C# application that asks the user to input the required data to implement the four methods below:
(Use Method Overloading to write the methods)
Method Addition that take as input two int values ‘a’ and ‘b’, calculates the sum, and displays it.
Method Addition that take as input three int values ‘a’ , ‘b’ and ‘c’, calculates the sum, and displays it.
Method Addition that takes as input two float values ‘p’ and ‘q’, calculates the sum, and displays it.
Method Addition that take as input three float values ‘p’ , ‘q’ and ‘r’, calculates the sum, and displays it.
Sample Input & Output muat be with commets on the excuting steps ex: // intiating class ...... etc..
thanks
Enter the first integer: ter the second integer Enter the third integer: Enter the first float value: .2 nter the second float value : .3 Enter the third float value 3.4 Sun of two integer numbers ? Sun of three integer numbers = 12 Sun of two float values Sun of three float values = 6.9 = 3.5Explanation / Answer
// application that asks the user to input the required data to implement the four methods,
// Using Method Overloading
using System.IO;
using System;
class Program
{
static void Main()
{
int x = 0,y = 0,z = 0;
float p = 0,q = 0,r = 0;
int result = 0, result1 =0;
float result2 = 0, result3 =0;
Console.WriteLine(">>> PROGRAM TO ADD TWO NUMBERS WITHOUT USING THIRD VARIABLE <<< ");
Console.Write(" Enter the first integer: ");
x =Convert.ToInt32(Console.ReadLine()); // taking x value from keyboard
Console.Write(" Enter the second integer: ");
y = Convert.ToInt32(Console.ReadLine()); // taking y value from keyboard
Console.Write(" Enter the third integer: ");
z =Convert.ToInt32(Console.ReadLine()); // taking z value from keyboard
Console.Write(" Enter the first float value: ");
p = float.Parse(Console.ReadLine()); // taking p value from keyboard
Console.Write(" Enter the second float value: ");
q = float.Parse(Console.ReadLine()); // taking q value from keyboard
Console.Write(" Enter the third float value: ");
r = float.Parse(Console.ReadLine()); // taking r value from keyboard
result= Addition(x,y); //calling function
result1 = Addition(x,y,z); // calling function
result2 = Addition(p,q); // calling function
result3 = Addition(p,q,r); // calling function
Console.WriteLine(" sum of two integer value = {0} ", result); /*printing the sum.*/
Console.WriteLine(" sum of three integer value = {0} ", result1); /*printing the sum.*/
Console.WriteLine(" sum of two float value = {0} ", result2); /*printing the sum.*/
Console.WriteLine(" sum of three float value = {0} ", result3); /*printing the sum.*/
//Console.ReadLine();
}
public static int Addition(int a, int b)
{
int x = 0;
return x=a+b;
}
public static int Addition(int a, int b,int c)
{
int y = 0;
return y = a + b+ c;
}
public static float Addition(float p, float q)
{
float u = 0;
return u = p + q;
}
public static float Addition(float p, float q, float r)
{
float v = 0;
return v = p + q+ r;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.