This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
prog of multiple inputs
nick kaushik
Ranch Hand
Joined: Sep 25, 2009
Posts: 48
I like...
posted
Sep 25, 2009 04:44:02
0
hi.... i want to take user input many times on command-line...the program replaces a char of user's choice with char of user's choice...
import java.io.*; public class Lb { public static void main(String arg[]) throws IOException { char a; BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); BufferedReader br1= new BufferedReader(new InputStreamReader(System.in)); BufferedReader br2= new BufferedReader(new InputStreamReader(System.in)); System.out.println("enter the text"); String s=br.readLine(); String s1; do { System.out.println("enter the char u want to replace"); char c=(char)br.read(); System.out.println("enter the replacement"); char r=(char)br1.read(); s1=s.replace(c,r); System.out.println(s1); System.out.println("replace again-y/n?"); a=(char)br2.read(); } while(a!='n'); System.out.println(s1); } }
i know that
String
Buffer should be used but still this program throws strange output....
"ye shall know the truth & the truth shall set you free..."
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8438
I like...
posted
Sep 25, 2009 04:46:20
0
Nick,
Please do
not
start multiple posts for essentially the same question. Let us continue the discussion at
http://www.coderanch.com/t/464056/Beginning-Java/java/multiple-inputs
Please read
http://faq.javaranch.com/java/UseOneThreadPerQuestion
for more details.
[
Donate a pint, save a life!
] [
How to ask questions
] [
Onff-turn it on!
]
I agree. Here's the link:
http://zeroturnaround.com/jrebel
- it saves me about five hours per week
subject: prog of multiple inputs
Similar Threads
How to convert a String to char
multiple inputs
Problem in file transfer
java program automatically chooses the default in switch on the next loop
Kindly help me
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter