> Hey, what would the code be to:
class LazyBones {
// declare instance variables
// constructor(s)
// method(s)
public static void main(String[] args) {
LazyBones me = new LazyBones();
me.fail();
}
}
Just fill in the gaps!
What you are trying to accomplish is somewhat advanced for a person just learning java.
I'd suggest reading through the Java tutorial here.
http://java.sun.com/docs/books/tutorial/getStarted/index.html
1) import the appropriate classes for the scanner
2) Use the API to find the appropriate methods you will need in order to convert the string into a char array.
3) Use a for loop to print the array backwards.
dforevergold has a head on his neck. So, I don't understand people saying about assignments etc... If he needs help and we can help then we must help.
Here's the code (but don't forget about comments!):
import java.util.Scanner;
public class Just {
public static void main(String[] args) {
// a scanner to get user's input
Scanner scan = new Scanner(System.in);
// Scanner.nextLine() returns the entered line
String name = scan.nextLine();
// toCharArray() converts a 'String' object to a 'char[]' object
char[] ch = name.toCharArray();
// next FOR-loop goes from the last element in the array to the first one and prints them onscreen
for (int i = ch.length - 1; i >= 0; --i) System.out.print(ch[i]);
}
}
I hope it helps you!
Yours Sincerely,
Nikaustr
> If he needs help and we can help
> then we must help.
Looks like you just made a friend for life. With the above statement you will be providing code for the rest of his/her school/college life. Can you do my work for me while I stay at home?
Message was edited by:
JStudent911
It took about 1 minute for me to write that code. So, if you have a one-minute job - I will be happy to help you ;)
I have a biological background, so I know that only BEST of the BEST will remain. Thus, if I am doing your job - you won't have a chance to become that "best of the best" ;)