hey!
I`m a beginner in Java and I want to write a program that use try and catch method to send a msg if the average it calculate is not in [0-20]
I have already write this code but it always print 0! what is wrong with my code?!!!
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
Avarage
{
class Program
{
static void Main(string[] args)
{
string n, m;
float f,s=0;
int i, k;
Console.Write("Please enter the number of your lessons :");
n =
Console.ReadLine();
i =
Convert.ToInt32(n);
for (int j = 0; j < i; j++)
{
Console.Write("please enter lesson's mark 1 by 1 and press Enter key :");
m =
Console.ReadLine();
k =
Convert.ToInt32(m);
s=s+k;
f = s / i;
}
try
{
if (f < 0 || f > 20)
}
catch
{
Console.WriteLine("You entered an unexpected number");
}
}
}
}