954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Spelling Backwards words

Im just a beginner but I find java exciting
can someone help me Im trying to write a program
to spell ambulance backwards I think im close but
I need somw help Im using strings to spell.
Ty. :sad:

Bill T
Newbie Poster
14 posts since Jul 2004
Reputation Points: 10
Solved Threads: 1
 

Greetings.
Hi. Post what you have done and we'll see how we could help you. ;)

red_evolve
Posting Whiz
313 posts since Jun 2003
Reputation Points: 53
Solved Threads: 1
 

public class Ambulance {
public static void main(String[] arg) { /*
String s1 = "E"; *
String s2 = "C"; *
String s3 = "N"; * This will spell Ambulance backwards
String s4 = "A"; * We HOPE
String s5 = "L"; *
String s6 = "U"; *
String s7 = "B"; *
String s8 = "M"; *
String s9 = "A"; */
System.out.println();
System.out.println("AMBULANCE = ECNALUBMA");

This is what ive done so far I can compile and no errors found but i execute and nothing happens... TY for your help but please I want to do the work.

Bill T
Newbie Poster
14 posts since Jul 2004
Reputation Points: 10
Solved Threads: 1
 

Greetings.
Umm...I guess what you want would be something like this:

public class Ambulance {
  public static void main(String[] arg) {
    String foo;
    char[] chr;

    foo = "Ambulance";
    chr = foo.toCharArray();    

    for(int i=foo.length()-1; i>=0; i--)
      System.out.print(chr[i]);
    
  }
}


However, to increase usability, I suggest that you code lines that prompts a string from the user.

red_evolve
Posting Whiz
313 posts since Jun 2003
Reputation Points: 53
Solved Threads: 1
 

ty for all of your help Ill try that and see what happens...

Bill T
Newbie Poster
14 posts since Jul 2004
Reputation Points: 10
Solved Threads: 1
 

I know it's been forever since anyone's said anything on this topic, but how do you prompt a string from the user ... ???

And is this java or javascript?

carenrose
Newbie Poster
1 post since May 2007
Reputation Points: 10
Solved Threads: 0
 

I think you cross posting, but if you want to get input from user in java, there are many way to do it. If you use new java compiler, you can use Scanner class, like:

Scanner scan = new Scanner (System.in);
String userPromt = scan.nextLine();


if you want to get user promt using java script:

prompt('Prompt text to the user','Suggest input for the user to enter')
nblue
Newbie Poster
16 posts since May 2004
Reputation Points: 10
Solved Threads: 2
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You