Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help with simple problem

 
julio torres
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
need to do a program that reads random number and then display
the string on character letter by letter
my code so far
import java.io.*;
public class a2n2
{

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


BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your Name:");
s = kb.readLine();

int count= s.length();
int pos=0;
char chs= s.charAt(pos);
chs = s.charAt(pos);
//System.out.println("letter:" + chs);

for ( pos=0; pos <= chs; count+);
{
count=pos + count;
System.out.println("display:"+ count);
}
}
}
please give me a hint on how to do this
i am stock on a simple program
 
julio torres
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by julio torres:
Sorry for the miss typo it is a random String to display
characters of the string one by one
need to do a program that reads random number and then display
the string on character letter by letter
my code so far
import java.io.*;
public class a2n2
{

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


BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your Name:");
s = kb.readLine();

int count= s.length();
int pos=0;
char chs= s.charAt(pos);
chs = s.charAt(pos);
//System.out.println("letter:" + chs);

for ( pos=0; pos <= chs; count+);
{
count=pos + count;
System.out.println("display:"+ count);
}
}
}
please give me a hint on how to do this
i am stock on a simple program

 
Jane Griscti
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Julio,
Try a for-loop to output the letters.

Hope that helps.
------------------
Jane
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The output of this program as written:
Enter your Name:
_
^
(cursor)
You have to Ctrl-C to interrupt it.
[This message has been edited by Marilyn deQueiroz (edited October 20, 2000).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic