sweetflip4suh
03-03-2006, 08:30 PM
import java.util.Scanner;
public class Hello
{
public static void main ( String [] args)
{
int x, y, z, firstDigit;
String p;
Scanner scan = new Scanner ( System.in);
System.out.print ( " Please enter a number ");
p = scan.nextLine();
int length = p.length();
for ( int j = 0; j < length; j++)
System.out.print ( p.charAt(j) + "");
System.out.println ();
System.out.println (" now in reverse");
for ( int j = length - 1; j >=0 ; j --)
System.out.print ( (p.charAt(j) + 5) + " " );
}
}
//// i have problem on this line System.out.print ( (p.charAt(j) + 5) + " " );
it adds the number 5 to j output..........but only numbers shows...
and i try to use ( char( (p.charAt(j) + 5) + " " ); but i get error about .class
how do i turn it to letters and not numbers
im basically tryin to turn the letters to another letter...( shifting it)
}
public class Hello
{
public static void main ( String [] args)
{
int x, y, z, firstDigit;
String p;
Scanner scan = new Scanner ( System.in);
System.out.print ( " Please enter a number ");
p = scan.nextLine();
int length = p.length();
for ( int j = 0; j < length; j++)
System.out.print ( p.charAt(j) + "");
System.out.println ();
System.out.println (" now in reverse");
for ( int j = length - 1; j >=0 ; j --)
System.out.print ( (p.charAt(j) + 5) + " " );
}
}
//// i have problem on this line System.out.print ( (p.charAt(j) + 5) + " " );
it adds the number 5 to j output..........but only numbers shows...
and i try to use ( char( (p.charAt(j) + 5) + " " ); but i get error about .class
how do i turn it to letters and not numbers
im basically tryin to turn the letters to another letter...( shifting it)
}