Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 6

184 ‫תרגילים‬

8 ‫תרגיל‬
class Program
{
static int Zugi(int num)
{
int counter = 0;
while (num > 0)
{
if (num % 2 == 0)
{
counter++;
}
num /= 10;
}
return counter;
}
static void Main(string[] args)
{
int num1, numberofnumbers, numsave = 0, sofer, bestnum =
0;
Console.WriteLine("how many number are there?");
numberofnumbers = int.Parse(Console.ReadLine());
for (int i = 0; i < numberofnumbers; i++)
{
Console.WriteLine("please enter a number");
num1 = int.Parse(Console.ReadLine());
sofer = Zugi(num1);
if (sofer > bestnum)
{
numsave = num1;
bestnum = sofer;
}
}
Console.WriteLine("the number that won is" + numsave);
}
}
}
8 ‫תרגיל‬
class Program
{
static int Mithalek (int num1, int num2)
{
int Isave = -1, b = 2;
for (int i = 100; i > b; i--)
{
if ((num1 % i == 0) && (num2 % i == 0))
{
Isave = i;
}
}
if (Isave != -1)
{
return Isave;
}
return -1;
}
static void Main(string[] args)
{
int n1, n2, result, sofer = 0;
for (int j = 0; j < 20; j++)
{
Console.WriteLine("please enter 2 numbers");
n1 = int.Parse(Console.ReadLine());
n2 = int.Parse(Console.ReadLine());
result = Mithalek(n1, n2);
if (result == -1)
{
sofer++;
}
}
Console.WriteLine("they were {0} numbers that dont
mithalkim", sofer);
}
}
}
9 ‫תרגיל‬
‫א‬. class Program
{
static bool Checker (char ch)
{
bool test = false;
if ((ch >= 65 && ch <= 67) || (ch >= 97 && ch <= 99))
{
test = true;
}
return test;
}
.‫ב‬
class Program
{
static void Main(string[] args)
{
char ch1;
int counter, lowestcounter = int.MaxValue;
for (int i = 0; i < 3; i++)
{
counter = 0;
Console.WriteLine("please enter letter when you done
type somthing that is not a letter");
ch1 = char.Parse(Console.ReadLine());
while ((ch1 >= 65 && ch1 <= 90) || (ch1 >= 97 && ch1
<= 122))
{
counter++;
ch1 = char.Parse(Console.ReadLine());
}
Console.WriteLine("this sidra has {0} letters",
counter);
if (counter < lowestcounter)
{
lowestcounter = counter;
}
}
Console.WriteLine("the lowerst sidra has {0} letters",
lowestcounter);
}
}
}
10 ‫תרגיל‬
class Program
{
public static int ProfMoney(int students)
{
int money = 0;
if (students >= 10)
{
money = 180;
money += (students - 10) * 5;
}
return money;
}

public static void Main(string[] angs)


{
int totalMoney = 0, casef, students;
for (int i = 1; i <= 3; i++)
{
Console.WriteLine("enter for class " + i);
students = int.Parse(Console.ReadLine());
casef = ProfMoney(students);
totalMoney += casef;
}
totalMoney /= 3;
Console.WriteLine("the avg money is {0} for each
proffesor", totalMoney);
}
}

You might also like