Вы находитесь на странице: 1из 5

1

INFORMATICS PRACTICES (2011) Class XII set B TYPE: PRACTICE PAPER F.M. : 50 Time : 1 hrs. Name :__________________________________________Sec :_____________Roll :_____________

5. Give the Errors and output of the following Expressions.


i) int a=10,b=10; Boolean c; c=++a<b; System.out.println(""+c); Output: false ii) Write the output of the following code:. Private void btnok MouseClicked() { int i=0; int x=5; for(i=1; i<=10;++i) { x = i++; System.out.println(+x); } System.out.println(+i); }

5 X 2 =10

Output: 1 2 3 4 5 6 7 8 9 10 10 iii) Write the output of the following code:. Private void btnokMouseClicked() { int j=0; int i=0; for(; i<2;i++) { j++; System.out.println("i="+i +"j=" +j); } for(;i++<5;) { j - -; } System.out.println("i=" +i + "j=" +j); }

2
Output: i=0 j=1 i=1 j=2 i=5 j=-1 Correct Output: i=1j=2 i=6j=-1

Iv ) private void btnokMouseClicked() { int i=5, j=5,y=5; for (i=6;i>=2;i- -) { for(;j>7; j++) { y = ++i + j++; } j++; } System.out.println(+y); } Output:

v) Write the Code: i) 1 35 7 9 11 13 15 17 19

ii) * ++ *** ++++

i)

for(int i=1; i<=4;i++) { for(j=1;j<=i;j=j+2) { System.out.print(+j); } System.out.println(); }

2.Create the following applications using NeateBeans IDE

a) In a company ,an employee is paid as follows : basicsalary DA HRA >=20000 20% 30% >=15000And <20000 15% 20% >=10000 and <15000 15% 15% >=5000 and <10000 12% 10% < 5000 0% 0%

10 PF 15% 15% 10% 5% 0% BONUS 10% 5% 5% 4% 5% GS ? ? ? ? ? 2 1 5 2 5 5

i) Write the code for btnclear button to clear the JTextFields. ii) Write the code for btnexit button to Exit the programs. iii) Calculate the net salary of an employee as Gs =bs +da +hra -pf+bonus iv) Write the command for the Enabled And Dissabled of JTextFields and btntotal,btnnetamount. C) Write a program for product of user input number like 5432 and calculate its product. Example 5x4x3x2=120 d) To Check the Number is Palindrome or not number accept by the user.

i) private void btnclear MouseClicked(){ jTextField1.setText(); jTextField2.setText(); jTextField3.setText(); jTextField4.setText(); jTextField5.setText(); jTextField6.setText(); }

ii)

private void btnexit MouseClicked(){

System.exit(0); }

iii)

int bs=Integer.parseInt(jTextField1.getText().trim()); double da,hra,pf,bonus,gs; if(bs<5000){ da=0; hra=0; pf=0; bonus=0.05*bs; } Else if(bs>=5000&&bs<10000) { Da=0.12*bs; Hra=0.10*bs; Pf=0.05*bs; Bonus=0.04*bs; } Else if(bs>=10000&&bs<15000) { Da=0.15*bs; Hra=0.15*bs; Pf=0.10*bs; Bonus=0.05*bs; } Else if(bs>=15000&&bs<20000) { Da=0.15*bs; Hra=0.20*bs; Pf=0.15*bs; Bonus=0.05*bs; } Else if(bs>=20000) { Da=0.20*bs; Hra=0.30*bs; Pf=0.15*bs; Bonus=0.10*bs; } Gs=bs+da+hra-pf+bonus; jTextField3.setText(+gs); private void btnenabled MouseClicked(){ jTextField1.setEnabled(true); jTextField2.setEnabled(true); jTextField3.setEnabled(true); jTextField4.setEnabled(true); jTextField5.setEnabled(true); jTextField6.setEnabled(true); btntotal.setEnabled(true); btnnetamount.setEnabled(true);

iv)

5 v) private void btnenabled MouseClicked(){ jTextField1.setEnabled(false); jTextField2.setEnabled(false); jTextField3.setEnabled(false); jTextField4.setEnabled(false); jTextField5.setEnabled(false); jTextField6.setEnabled(false); btntotal.setEnabled(false); btnnetamount.setEnabled(false); int a=Integer.parseInt(Jtxt1.getText().trim()); String i=jTextField1.getText().trim(); int a=0,k=1; for(;a<i.length();a++) { char ch=i.charAt(a); int j=(int)ch; j=j*j; System.out.println(""+j); }

vi)

Вам также может понравиться