Net Bean Java (Informatics Practices) Practical File For Class 12
This document contains code to reverse a number entered by a user. The code uses a do-while loop to extract each digit of the input number and add it to the reversed number. It takes the input number, initializes a reversed variable to 0, extracts the ones place digit using modulo 10, multiplies the reversed number by 10 and adds the digit, then divides the input by 10 to remove the ones place until the input reaches 0. It displays the original and reversed number for the user.
Download as DOC, PDF, TXT or read online on Scribd
100%(1)100% found this document useful (1 vote)
380 views
Net Bean Java (Informatics Practices) Practical File For Class 12
This document contains code to reverse a number entered by a user. The code uses a do-while loop to extract each digit of the input number and add it to the reversed number. It takes the input number, initializes a reversed variable to 0, extracts the ones place digit using modulo 10, multiplies the reversed number by 10 and adds the digit, then divides the input by 10 to remove the ones place until the input reaches 0. It displays the original and reversed number for the user.
int a = Integer.parseInt (t1.getText ()); int b = a; int d=0; do { int c = a%10; d=d*10+c; a = a/10; }while(a!=0); t2.setText ("Mirror Image Of " + b + " is " + d);