-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
147 lines (116 loc) · 3.76 KB
/
Program.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
int a;
int b;
int mod;
int sd;
public void oddEven()
{
Console.WriteLine("Enter a number::");
a = Convert.ToInt32(Console.ReadLine());
if (a % 2 == 0)
{
Console.WriteLine("The number {0} is even", a);
}
else
{
Console.WriteLine("The number {0} is odd", a);
}
Console.ReadLine();
}
public int Add()
{
Console.WriteLine("Enter two number::");
a = Convert.ToInt32(Console.ReadLine());
b = Convert.ToInt32(Console.ReadLine());
return a == b ? (a + b) * 3 : a + b;
Console.WriteLine("The sum of two numbers {0} and {1} is {2}", a, b, a + b);
}
public void Nums()
{
Console.WriteLine("Enter number::");
a = Convert.ToInt32(Console.ReadLine());
while (a > 0)
{
mod = a % 10;
sd = sd + mod;
a = a / 10;
}
Console.WriteLine("The sum of two numbers {0}", sd);
}
public void Rev()
{
Console.WriteLine("Enter number::");
a = Convert.ToInt32(Console.ReadLine());
while (a > 0)
{
mod = a % 10;
sd = sd*10 + mod;
a = a / 10;
}
Console.WriteLine("The reverse of number is {0}",sd );
}
public bool check(int a, int b)
{
//Console.WriteLine("Enter two number::");
// a = Convert.ToInt32(Console.ReadLine());
// b = Convert.ToInt32(Console.ReadLine());
return(a==30 || b==30 || (a + b)==30);
// Console.WriteLine("The sum of two numbers {0} and {1} is {2}", a, b, a + b);
}
public bool multiple(int a)
{
return (a % 3 == 0 || a % 7 == 0);
}
public void Menu()
{
int choice;
Console.WriteLine("1.OddEven \n 2.Add 2 num \n 3.digitSum \n 4.Reverse \n 5.Return true if one of them is 30 \n 6.Multiple of 3 or 7\n");
Console.WriteLine("Enter your choice::");
choice = Convert.ToInt32(Console.ReadLine());
switch (choice)
{
case 1:
oddEven();
break;
case 2:
Add();
break;
case 3:
Nums();
break;
case 4:
Rev();
break;
case 5:
Console.WriteLine(check(10,20));
Console.WriteLine(check(10,0));
Console.WriteLine(check(30,0));
break;
case 6:
Console.WriteLine(multiple(7));
Console.WriteLine(multiple(3));
Console.WriteLine(multiple(5));
Console.WriteLine(multiple(2));
break;
}
}
public static void Main(string[] args)
{
int a;
int b;
Program program = new Program();
while (true)
{
program.Menu();
}
}
}
}