-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOverloadedSurpriseFunction.cs
125 lines (99 loc) · 3.31 KB
/
OverloadedSurpriseFunction.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
using System;
class Program
{
public static void Main(string[] args)
{
string type;
Console.WriteLine("[Overloaded Surprise Function]");
Console.Write("What data type do you want to enter? ");
type = Console.ReadLine();
switch(type){
case "string":
string stringOne, stringTwo;
Console.Write("Value #1: ");
stringOne = Console.ReadLine();
Console.Write("Value #2: ");
stringTwo = Console.ReadLine();
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(stringOne, stringTwo));
break;
case "float":
float floatOne, floatTwo;
Console.Write("Value #1: ");
floatOne = float.Parse(Console.ReadLine());
Console.Write("Value #2: ");
floatTwo = float.Parse(Console.ReadLine());
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(floatOne, floatTwo));
break;
case "char":
char charOne, charTwo;
Console.Write("Value #1: ");
charOne = char.Parse(Console.ReadLine());
Console.Write("Value #2: ");
charTwo = char.Parse(Console.ReadLine());
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(charOne, charTwo));
break;
case "double":
double doubleOne, doubleTwo;
Console.Write("Value #1: ");
doubleOne = Convert.ToDouble(Console.ReadLine());
Console.Write("Value #2: ");
doubleTwo = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(doubleOne, doubleTwo));
break;
case "integer":
int intOne, intTwo;
Console.Write("Value #1: ");
intOne = Convert.ToInt32(Console.ReadLine());
Console.Write("Value #2: ");
intTwo = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(intOne, intTwo));
break;
case "boolean":
bool boolOne, boolTwo;
Console.Write("Value #1: ");
boolOne = Convert.ToBoolean(Console.ReadLine());
Console.Write("Value #2: ");
boolTwo = Convert.ToBoolean(Console.ReadLine());
Console.WriteLine("Calling surprise_function()...");
Console.WriteLine("The result is " + surprise_function(boolOne, boolTwo));
break;
}
}
public static int surprise_function(int a, int b)
{
int sum = a + b;
return sum;
}
public static string surprise_function(char a, char b)
{
return a + ""+ b;
}
public static float surprise_function(float a, float b)
{
return a / b;
}
public static double surprise_function(double a, double b)
{
return a % b;
}
public static String surprise_function(string a, string b)
{
return a + b;
}
public static bool surprise_function(bool a, bool b)
{
if (a && b)
{
return true;
}
else
{
return false;
}
}
}