M.P.SANJAY
| Subject: JAVA HELP req. in String programs -MP Sanjay Sun Aug 17, 2008 11:06 am | |
| WRITE A PROGRAM:
1) TO ACCEPT THE SENTENCE AND DISPLAY THE WORDS IN SEPARATE LINE.
2) TO ACCEPT A SENTENCE AND DISPLAY ONLY THE 3 LETTERED WORDS ON A SEPARATE LINE.
3) TO ACCEPT TWO SENTENCES AND THEN JOIN THEM.
4) TO ACCEPT A WORD AND THEN REVERSE THE LETTERS.
5) TO ACCEPT A SENTENCE AND REPLACE 'THE' WITH 'AN'.
PLEASE SEND IT AS FAST AS POSSIBLE |
|
abhas Active member
| |
abhas Active member
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay Mon Aug 25, 2008 9:31 pm | |
| 3rd one is very very easy import java.io.*; class str1 { public static void main(String args[]) throws IOException { BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter sentence"); String s=obj.readLine();
System.out.println("Enter sentence"); String s2=obj.readLine();
String s3=s1 s2; //or String s3=s1 " " s2; if u want to add space System.out.println(s3);
} } |
|
abhas Active member
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay Mon Aug 25, 2008 9:36 pm | |
| if u are having any prob. in logic of any of these program then please post ur incorrect progs. here and i will try to correct them it would be better....
its diff. for me to type each program and give it to u..
i may debug ur progs. |
|
abhas Active member
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay Thu Aug 28, 2008 6:26 pm | |
| 4) TO ACCEPT A WORD AND THEN REVERSE THE LETTERS. public class stringr { void main(String check) { int a = check.length(); for (int c=a-1;c>=0;c--) { System.out.print(check.charAt(c)); ch=ch+1; }
} } |
|
akshay Active member
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay Wed Feb 18, 2009 8:43 am | |
| 5th one is extremely short: import java.io.*; class strings { public static void main() throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter a sentence"); String s=in.readLine(); s= s.replace("the","an"); System.out.println(s); } } |
|
akshay Active member
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay Wed Feb 18, 2009 8:43 am | |
| here's the 2nd one also: import java.io.*; class threeletterword { public static void main() throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter a sentence"); String s=in.readLine(); s=s.trim(); s=s+" "; int len=s.length(); int len1,k,count; String word= new String(); for (int i=0;i<len;i++) { k=s.indexOf(" ",i); word=s.substring(i,k); len1=word.length(); if (len1==3) System.out.println(word); i=k; }}}
=) |
|
agentp.1994
| Subject: hey!here is the 4th one... Fri Nov 06, 2009 8:49 pm | |
| class abc { void getname(String s1) { String s3=""; for(int i=s1.length-1;i>=0;i--) { char ch =s1.charAt(i); s3=s3+ch; } System.out.print(s3); } } eg:life =efil.. |
|
Sponsored content
| Subject: Re: JAVA HELP req. in String programs -MP Sanjay | |
| |
|