𝙔⁴⁴
𝙔⁴⁴
CC#
Created by 𝙔⁴⁴ on 1/14/2023 in #help
❔ hw help
using System;

public class Program
{
public static int CountEven (int num)
{
int digit;
int evencount = 0;
while (num != 0)
{
digit = num % 10;
if (num % 2 == 0)
{
evencount++;
}
num = num/10;
}
return evencount;
}
public static void Main()
{
int n;
Console.WriteLine("Write how many numbers are there?");
n = int.Parse(Console.ReadLine());
for ( int i = 1 ; i <= n ; i++)
{
int c;int y = 0;int Max = 0;
c= int.Parse(Console.ReadLine());
Console.WriteLine( "This number has this much even numbers: " + CountEven(c));
if (CountEven(c) > y)
{
y = CountEven(c);
Max = Math.Max(y,Max);
Console.WriteLine("This number has the most even numbers:" + Max);
}
}
}
}
using System;

public class Program
{
public static int CountEven (int num)
{
int digit;
int evencount = 0;
while (num != 0)
{
digit = num % 10;
if (num % 2 == 0)
{
evencount++;
}
num = num/10;
}
return evencount;
}
public static void Main()
{
int n;
Console.WriteLine("Write how many numbers are there?");
n = int.Parse(Console.ReadLine());
for ( int i = 1 ; i <= n ; i++)
{
int c;int y = 0;int Max = 0;
c= int.Parse(Console.ReadLine());
Console.WriteLine( "This number has this much even numbers: " + CountEven(c));
if (CountEven(c) > y)
{
y = CountEven(c);
Max = Math.Max(y,Max);
Console.WriteLine("This number has the most even numbers:" + Max);
}
}
}
}
now i want this code to show me the number that has the most even numbers but it keeps showing me how much even numbers the numbers has instead even tho i have the max command
7 replies