Hi
I have this assignment to do. Input ten words into and output them backwards, include there in a for loop. Can anyone please help?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi
I have this assignment to do. Input ten words into and output them backwards, include there in a for loop. Can anyone please help?
yuvarekha (July 26th, 2019)
Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.
Show what you've done so far, posted correctly per the above link, and ask any specific questions you have. We can't do it for you.
import java.io.*;
import javax.swing.*;
public class SkrivaOrd {
public static TioOrd {
String s = JOptionPane.showInputDialog("Input ten words ");
for (int i=s.length()-1; i>=0; i--)
s = s + s.charAt(i);
return r;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
}
}
I have done this so far. Im struggling with this.
Please post your code using code or highlight tags as explained near the top of this topic.
Think through the assignment and match the requirements to what a program needs to do, then put that into a rough outline based on what you know or should know in Java. For example:
1. Input ten words: How is that done? Since it's a repeated activity, a loop might be useful. Where will the values be stored? In an array or other collection? In 10 different variables? How will the user input be retrieved? Check out the Scanner class.
2. output them backwards: How is data output to the console? Again, a repeated activity, so a loop should be helpful. Since the data is output backwards, all 10 items of data must be collected before they can be output.
3. include a for loop: Suggested in #1 and #2.