| | |
need help to create a java program
![]() |
Hi Kumar,
Attempt to do your homework yourself, and then we can help you along the way. We do not do homework for you here.
Ed
Attempt to do your homework yourself, and then we can help you along the way. We do not do homework for you here.
Ed
•
•
•
•
Originally Posted by kumar25
hi all,
i am a beginner in java programming.Could anyone please provide source code for the following program.
A program that reads a integer and breaks it into a sequence of individual digits in reverse order.TQ.
•
•
•
•
In a world without walls or fences,
What use are Windows and Gates.
If you're having trouble try reading in the integers into an array. Or you could turn the string into an array with the CopyTo() method or ToArray() methods.
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
Here is how to reverse an inputed string, just apply it all to Int and you should have your program:
class ReverseString
class TestReverse
class ReverseString
Java Syntax (Toggle Plain Text)
public class ReverseString { public String reverse(String arg) { String tmp = null; if (arg.length() == 1) { return arg; } else { //extract the last char String lastChar = arg.substring(arg.length()-1,arg.length()); //extract the remaining chars String remainingString = arg.substring(0, arg.length() -1); tmp = lastChar + reverse(remainingString); return tmp; } } }
class TestReverse
Java Syntax (Toggle Plain Text)
import java.io.*; public class TestReverse { public static void main(String[] args) throws IOException { System.out.println("Enter a line to be reversed"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String inData; inData = br.readLine(); ReverseString rs = new ReverseString(); System.out.println("Reversed: " + rs.reverse(inData)); } }
•
•
Join Date: Sep 2004
Posts: 35
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by server_crash
Here is how to reverse an inputed string, just apply it all to Int and you should have your program:
class ReverseString
Java Syntax (Toggle Plain Text)
public class ReverseString { public String reverse(String arg) { String tmp = null; if (arg.length() == 1) { return arg; } else { //extract the last char String lastChar = arg.substring(arg.length()-1,arg.length()); //extract the remaining chars String remainingString = arg.substring(0, arg.length() -1); tmp = lastChar + reverse(remainingString); return tmp; } } }
class TestReverse
Java Syntax (Toggle Plain Text)
import java.io.*; public class TestReverse { public static void main(String[] args) throws IOException { System.out.println("Enter a line to be reversed"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String inData; inData = br.readLine(); ReverseString rs = new ReverseString(); System.out.println("Reversed: " + rs.reverse(inData)); } }
plz don't do like this..................
they should do the hw themselvs
![]() |
Similar Threads
- I need help in developing my java program! (Java)
- Need help about Java program or C++ program? (C#)
- Run Unix Find command using java Program (Java)
- Help with Java program writing (Java)
Other Threads in the Java Forum
- Previous Thread: Jdic
- Next Thread: Help With Contstructors
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows





