Here's the replica of the widely used Mod Function (%). You may even use it in your program as :
// Rest part of the program is omitted
int m=39,n=7,result;
result=mod.cal(m,n);
System.out.print(result);
Java Program :
class mod
{
static int cal(int number,int mod)
{
for(;;)
{
if(number>=mod)
number=number-mod;
else
return number;
}
}
}
// Rest part of the program is omitted
int m=39,n=7,result;
result=mod.cal(m,n);
System.out.print(result);
Java Program :
class mod
{
static int cal(int number,int mod)
{
for(;;)
{
if(number>=mod)
number=number-mod;
else
return number;
}
}
}
You need not use this function, but this program will definitely make your Blue J project nicer to look at.
ReplyDeleteThanks for this wonderful post ! Please keep it up ! You haven't been posting for days, so please start posting once again.
ReplyDelete