Reverse word for Java code HELP!

U

usatoday

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

The project is Reversewords.
We have to design a function that will take a string of words and hand
it back to the caller with all the words reversed (E.g. "i like you"
becomes "you like i"). Use two nested for loops in the routine to get
your result. Afterwards, in the main, continue asking the user for a
sentence- or just type return to end (can use while loop in main).

this is what I got so far.

public class Reversewords
{
public static void main(String [] args)
{
Scanner inputreader=new Scanner(System.in);
int 0 = sen.getLength()-1;
int c = 0;
}
for (c=orj; c>0; c--)
{
if (sen.charAt(c)=='')
{
String sb = sen.substring(c+1,ori+1);
system.out.print(sb)" ";
ori = c;
}
}
 
R

RedGrittyBrick

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

Relax, if you don't understand Java and are a Java idiot, it would be
unkind to propel you into a job where you need to know Java.

Chill out and spend the time looking for some course subjects that you
actually enjoy and are motivated to learn.
 
L

Luuk

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

The project is Reversewords.
We have to design a function that will take a string of words and hand
it back to the caller with all the words reversed (E.g. "i like you"
becomes "you like i"). Use two nested for loops in the routine to get
your result. Afterwards, in the main, continue asking the user for a
sentence- or just type return to end (can use while loop in main).

this is what I got so far.

public class Reversewords
{
public static void main(String [] args)
{
Scanner inputreader=new Scanner(System.in);
int 0 = sen.getLength()-1;

I did not know JAVA accepts numeric named variables...
 
B

Bent C Dalager

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

Regardless of what you're actually trying to accomplish with the below
program, it has a number of errors that will prevent it from even
compiling.
public class Reversewords
{
public static void main(String [] args)
{
Scanner inputreader=new Scanner(System.in);

The compiler needs to be told where to find the Scanner class.
int 0 = sen.getLength()-1;

You can't call something "0" and there is nothing called "sen".
int c = 0;
}
for (c=orj; c>0; c--)

This for statement is outside of any method, and you probably want it
to be inside of one. There is nothing called "orj".
{
if (sen.charAt(c)=='')

'' isn't a valid character constant.
{
String sb = sen.substring(c+1,ori+1);

Again, nothing is actually called "sen", and there is also nothing
called "ori".
system.out.print(sb)" ";

You can't follow a method call with an immediate ".

And there is nothing called ori.

Finally, the file seems to end before the class does.

Cheers,

Bent D.
 
R

Roedy Green

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

The project is Reversewords.
We have to design a function that will take a string of words and hand
it back to the caller with all the words reversed (E.g. "i like you"
becomes "you like i"). Use two nested for loops in the routine to get
your result. Afterwards, in the main, continue asking the user for a
sentence- or just type return to end (can use while loop in main).

this is what I got so far.

public class Reversewords
{
public static void main(String [] args)
{
Scanner inputreader=new Scanner(System.in);
int 0 = sen.getLength()-1;
int c = 0;
}
for (c=orj; c>0; c--)
{
if (sen.charAt(c)=='')
{
String sb = sen.substring(c+1,ori+1);
system.out.print(sb)" ";
ori = c;
}
}

you are flummoxing. See http://mindprod.com/jgloss/tackling.html for
how to break the problem into manageable pieces.
--
Roedy Green Canadian Mind Products
http://mindprod.com
To err is human, but to really foul things up requires a computer.
~ Farmer,s Almanac
It is breathtaking how a misplaced comma in a computer program can
shred megabytes of data in seconds.
 
E

Eric Sosman

I got to finish this project by tomorrow, but I really don't know how
to. If I don't finish it, I will be doomed:( I don't understand java
AT ALL, I AM A JAVA IDIOT. Please help me! your help will be
appreciated!

The project is Reversewords.
We have to design a function that will take a string of words and hand
it back to the caller with all the words reversed (E.g. "i like you"
becomes "you like i").[...]

Suggested solution method: First, find the length of the original
string; for "i like you" this would be ten. Then generate all ten-
character strings in turn, and append each to "i like you". Test
each concatenation to see whether it's a palindrome; if it is, the
generated string is the reverse of the original!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help in hangman game 1
Java 1
Could someone help me and explain what is wrong here? 4
Java matrix problem 3
Help with code 0
Code help please 4
Need help for javascript code 3
Help with code plsss 0

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top