Data input
I am a student from class 10th. I wish to make a program which first shows a choice and does it work accordingly. I asked for the help of my teacher but his program seems to give errors during compilation.
class menu
{//1
DataInputStream obj=new DataInputStream(System.in);
void main()
throws java.io.IOException
{//2
int m=0;
int n=0;
int temp,d,s=0;
do
{//3
System.out.println("1.Armstrong Number");
System.out.println("2.Palindrome Number");
System.out.println("3.Prime Number");
System.out.println("4.Exit");
System.out.println("Enter choice");
ch=Integer.parseInt(obj.readLine());
if (ch!=4)
{//4
System.out.println("Enter Start Limit");
m=Integer.parseInt(obj.readLine());
System.out.println("Enter End Limit");
n=Integer.parseInt(obj.readLine());
}//4
switch (ch)
{//5
case 1:
for (int i=m; i<=n; i++)
{//6
temp=i;
while (temp!=0)
{//7
d=temp%10;
s+=d*d*d;
temp/=10;
}//7
if (s==i) System.out.println(i);
s=0;
}//6
break;
case 2:
for (int i=m; i<=n; i++)
{//8
temp=i;
while (temp!=0)
{//9
d=temp%10;
s=s*10+d;
temp/=10;
}//9
if (s==i) System.out.println(i);
s=0;
}//8
break;
case 3:
for (int i=m; i<=n; i++)
{//10
for (int j=1; j<=i; j++)
{
if (i%j==0) s++;
}
if (s==2) System.out.println(i);
s=0;
}//10
break;
case 4: System.out.println("over");
}//5
}
while (ch!=4);//3
}//2
}// end of 1
Please help me with this program to remove the errors ands please do tell me about asking for valid inputs druing program run in java.
Thanks a lot in advance.
Ritwik

