Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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.

Uploaded by

Sanjeet
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
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.

Uploaded by

Sanjeet
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Q1.

Application to input a number and display its reverse (using do…while loop)

private void clearActionPerformed(java.awt.event.ActionEvent evt) {


t1.setText ("");
t2.setText ("");// TODO add your handling code here:
}

private void exitActionPerformed(java.awt.event.ActionEvent evt) {


System.exit(0);
// TODO add your handling code here:
}

private void mirrorimageActionPerformed(java.awt.event.ActionEvent evt) {


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);

You might also like