Академический Документы
Профессиональный Документы
Культура Документы
int a;
int c=0;
for(a=2;a<=100;a=a+2)
{
if (c==10)
{
c=0;
jTextArea1.append("\n");
}
jTextArea1.setText(jTextArea1.getText()+" "+a);
c=c+1;
}
int a;
int c=0;
for(a=99;a>=1;a=a-2)
{
if (c==10)
{
c=0;
jTextArea1.append("\n");
}
jTextArea1.setText(jTextArea1.getText()+" "+a);
c=c+1;
}
4.WAP to input any number and check whether it is Prime number or not
ANS. int a=Integer.parseInt(jTextField1.getText());
int i,f;
f=0;
for(i=2;i<=a-1;i++)
{
if(a %i==0)
f=1;
}
if(f==0)
jLabel2.setText("Number is prime");
else
jLabel2.setText("number is not prime");
}
5.WAP to input any year and check whether it is leap year or not
ANS. int a=Integer.parseInt(jTextField1.getText());
if( a % 4 ==0)
jLabel2.setText(a + " is a leap year");
else
jLabel2.setText(a + " is not a leap year");
}
Screen shots………
Ques 1
Ques 2
Ques 3
Ques 4.
Ques 5
6Wap to input a numbe r and display its fatorial
7Wap to input x and y and display x to the power of y