I need BlueJ codes for these questions, and fast... PLZ... I have lab practicals tomorrow....
1)input char and check if it is alphabet, no., special char
2) to find factors of an inputted number
3)to find the factorial of inputted number
4)print multiplication table of inputted no.
5) accept month nos., and print no. of days in the month.Also check of leap yrs..
PLEASE FAST
Answers
Answered by
0
2.
class Factor
{
static void main(int n)
{
int i;
for(i=1; i<=n; i++)
{
if(n%i==0)
{
System.out.print(i);
}
}
}
}
3.
class Factorial
{
static void main(int n)
{
int i, m=1;
for(i=1; i<=n; i++)
{
m=m*i;
}
System.out.print(m);
}
}
4.
class Table
{
static void main(int n)
{
int i, m=0;
for(i=1; i<=10; i++)
{
m=n*i;
System.out.print(i+"*"+n+"="+m);
}
}
}
5.
class Days
{
void main(int n)
{
switch(n)
{
case 1:
System.out.print("31 days");
break;
case 2:
System.out.print("28 days or 29 days");
break;
case 3:
System.out.print("31 days");
break;
case 4:
System.out.print("30 days");
break;
case 5:
System.out.print("31 days");
break;
case 6:
System.out.print("30 days");
break;
case 7:
System.out.print("31 days");
break;
case 8:
System.out.print("31 days");
break;
case 9:
System.out.print("30 days");
break;
case 10:
System.out.print("31 days");
break;
case 11:
System.out.print("30 days");
break;
case 12:
System.out.print("31 days");
break;
default:
System.out.print("this number month does not exist");
}
}
}
class Factor
{
static void main(int n)
{
int i;
for(i=1; i<=n; i++)
{
if(n%i==0)
{
System.out.print(i);
}
}
}
}
3.
class Factorial
{
static void main(int n)
{
int i, m=1;
for(i=1; i<=n; i++)
{
m=m*i;
}
System.out.print(m);
}
}
4.
class Table
{
static void main(int n)
{
int i, m=0;
for(i=1; i<=10; i++)
{
m=n*i;
System.out.print(i+"*"+n+"="+m);
}
}
}
5.
class Days
{
void main(int n)
{
switch(n)
{
case 1:
System.out.print("31 days");
break;
case 2:
System.out.print("28 days or 29 days");
break;
case 3:
System.out.print("31 days");
break;
case 4:
System.out.print("30 days");
break;
case 5:
System.out.print("31 days");
break;
case 6:
System.out.print("30 days");
break;
case 7:
System.out.print("31 days");
break;
case 8:
System.out.print("31 days");
break;
case 9:
System.out.print("30 days");
break;
case 10:
System.out.print("31 days");
break;
case 11:
System.out.print("30 days");
break;
case 12:
System.out.print("31 days");
break;
default:
System.out.print("this number month does not exist");
}
}
}
Similar questions