Reverse Numbers



Hi
In the following program, what ever digits are typed into the inputbox
I want them displayed in reverse order in the status bar. At the moment
only the first digit appears in the status bar. I can't see where i'm
going wrong. Maybe someone can take a look.
Cheers Ian

import java.awt.event.*;
import java.awt.*;
import javax.swing.*;

public class Reverse extends JApplet implements ActionListener {
JTextField inputField;
JLabel prompt;

// set up GUI components
public void init()
{
prompt = new JLabel( "Enter Digits:" );
inputField = new JTextField( 4 );
inputField.addActionListener( this );

Container container = getContentPane();
container.setLayout( new FlowLayout() );
container.add( prompt );
container.add( inputField );

} // end method init

// call method qualityPoints if user input is within range
public void actionPerformed( ActionEvent actionEvent )
{
int inputNumber = Integer.parseInt( inputField.getText() );


if ( inputNumber != 0 ){
showStatus( "Reversed is: " + qualityPoints( inputNumber ) );}
else
showStatus( "Invalid input." );

} // end method actionPerformed

// return single digit value of grade
public int qualityPoints( int num)
{
int rightDigit =0;
int newnum = 0;

rightDigit = num % 10;
newnum = newnum * 10 + rightDigit;
num = num / 10;

return num;

} // end method qualityPoints

} // end class Reverse

.



Relevant Pages

  • Re: [RFC] New kernel-message logging API
    ... return buf; ... static char* put_dec(char *buf, unsigned long long num) ... static int skip_atoi ...
    (Linux-Kernel)
  • Re: Ex 7-5
    ... void clearStack; ... I don't interpret the suggestion to rewrite to use scanf ... // Tondo and Gimpel has the next declaration wrongly an int ... double num; ...
    (comp.lang.c)
  • Re: Ex 7-5
    ... int getop; ... double num; ... allowed me to get whatever stack values I wanted in the first ... void clearStack; ...
    (comp.lang.c)
  • problem in java question
    ... on the applet and ask another multiplication question. ... public int question() ... public void actionPerformed(ActionEvent actionEvent) ...
    (comp.lang.java.programmer)
  • Re: sob..Someone can help me????plsss
    ... main returns an int. ... float num1,num2,num3,num4; ... Note that scanf doesn't touch num if ... use scanf() unless there is no better choice. ...
    (comp.lang.c)