its again java problem - Sajha Mobile
SAJHA MOBILE
its again java problem
Posts 6 · Viewed 6539 · Go to Last Post
redlotus
· Snapshot
Like · Likedby · 0

JAVA 101 level:


Write a Java application that creates an instance of the String class and initializes this instance with a String literal. Use a for loop structure to print the string in reverse order. Implement the following two String member methods to complete the assignment.




  • length( )


  • charAt( )

Write a program to test your class MyStringTest.


Continue to properly document your source code. Write this program as if you were explaining it to someone new to arrays. Fully document your code in such a way newcomers to Java will understand and be able to implement a Java array. Your grade on this assignment will be based on your thoroughness of documentation as well as you correctness of code.

sathi_meroo
· Snapshot
Like · Liked by · 0
I haven't used sajha for quite a long time, but I think Techguy is still around who can help you, lahure dai is also another option, but if u keep on posting ur assignments in the forums then u r not going to learn anything bro... It clearly mention u r not giving any effort to it, so I suggest you first u should try to do it by urself and post where u went wrong, or in which part of the codes u are confused. If it interests u to visit other forums then http://www.java-forums.org/ is better option for java related problems, most of them will be willing to help you, so, have a luck....
madhab6
· Snapshot
Like · Liked by · 0

here u go dude:


import java.io.*;


public class MyStringTest {


            public static void main(String[] args) throws IOException {


                BufferedReader rd = new BufferedReader (


                new InputStreamReader(System.in));


                System.out.print("Enter the string that needs to be reversed: ");


                String S = rd.readLine();


                 System.out.print("The reversed string is: ");


          for(int i=S.length()-1;i>=0; i--)


{


char c=S.charAt(i);


System.out.print(c);


}


}


}


 


Hope this would of some help :D

DilipYogi
· Snapshot
Like · Liked by · 0
Have send u an email through sajha..should have got it. :)
LahureDai
· Snapshot
Like · Liked by · 0
redlotus,

I understand that you are very new to Java, but you should at least allocate some time to ponder the problems. Instead of asking people to write the entire code for ya, you need to put some effort on it. Nobody is perfect, so asking for help is not bad. But asking people to do the entire homework is so absurd.
I am assuming that you are taking java now in the hope of getting a job in the IT field. If you don't aggregate enough knowledge in java now, you won't be able to keep your job!
Since it is 100 level course, it is not that hard to learn if you have self determination to learn java. You are welcome to post java problems in sajha, but please try on your own first.

Good luck,
khai_k_khai_k
· Snapshot
Like · Liked by · 0
Please try to solve it by yourself first and if possible post your errors/exception rather than posting the question.

public class StringProblem {
    private String stringInstance;
    private char[] splittedString;

    public StringProblem(String initString) {
        stringInstance = new String(initString);
        splittedString = stringInstance.toCharArray();
    }

    public int length() {
        return splittedString.length;
    }

    public char charAt(int index) {
        return splittedString[index];
    }

    public static void main(String[] args) {
        StringProblem strProb = new StringProblem("NEPAL");
        
        for (int i = strProb.length() - 1; i >= 0; i--) {
            System.out.print(strProb.charAt(i) + " ");
        }
    }
}
Please log in to reply to this post

You can also log in using your Facebook
View in Desktop
What people are reading
You might like these other discussions...
· Posts 9 · Viewed 12782 · Likes 1
· Posts 7 · Viewed 4273 · Likes 1
· Posts 1 · Viewed 1174
· Posts 1 · Viewed 1195
· Posts 1 · Viewed 1092
· Posts 1 · Viewed 1175
· Posts 1 · Viewed 1135
· Posts 21 · Viewed 10498 · Likes 1
· Posts 3 · Viewed 2787
· Posts 5 · Viewed 7985 · Likes 1



Your Banner Here
Travel Partners
Travel House Nepal