English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

import java.io.*;


public class Test {
static java.io.PrintStream o = java.lang.System.out;
public static void main(String[] args)throws Exception {

BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter plot for printing: ");
String s = BR.readLine();



char[] cs = s.toLowerCase().toCharArray();



for(int i=0, j=0; i < cs.length-0x1; i+=0x2, j=0)
{
while(j++ < (int)(cs[i]-0x30))
{
o.print((char)(cs[i+0x1]-0x20));
}
}


}
}


I dont take full credit in making this but I want to modify it so that it can take multiple inputs separated by space, I tried to use tokenizer but I dont know how exactly will I use it because I get errors in compiling.


the goal is it should come out like this example:


Enter plot for printing: 3b1o3b 1b4o1b 3b1o3b


output:

BBBOBBB
BOOOOB
BBBOBBB

2007-01-28 23:27:25 · 3 answers · asked by wata_tempora 1 in Computers & Internet Programming & Design

3 answers

01 public class Test
02 {
03    static java.io.PrintStream o = java.lang.System.out;
04
05    public static void main(String[] args)throws Exception {
06
07        BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
08        System.out.print("Enter plot for printing: ");
09        String s = BR.readLine();
10
11        String delimiter = " "; //string to split the given one by
12        String[] tokenzArray = s.split( delimiter ); //our tokenz array
13
14        //for each string(token) in our tokenzArray
15        for ( String token: tokenzArray ){
16
17            //char[] cs = s.toLowerCase().toCharArray();
18            char[] cs = token.toLowerCase().toCharArray();
19
20            for(int i=0, j=0; i < cs.length -1; i +=2, j=0){
21
22                while(j++ < (int)(cs[i] -0x30))
23                {
24                    //o.print((char)(cs[i+0x1]-0x20));
25                    //Don't convert from lower to upper like that,
26                    //it will cause runtime errors if you tried it with numbers
27                    //since there is no Capital number or Small number!
28                    //Use this instead:
29                    o.print( String.valueOf( cs[i +1] ).toUpperCase() );
30                }
31            }
32
33            //print a new line after each token
34            o.println();
35        }
36    }
37 }

Note that you can use java.util.StringTokenizer, but it has been retained for combatibility reasons, and using it in new codes is considered as bad programming practice; String.split(arg0) is the one should be used instead.

Thanks

2007-01-29 00:20:10 · answer #1 · answered by Fox 3 · 0 0

i be attentive to there are various solutions already right here, yet first I propose you to verify C then C++ and next your determination. C and C++ supplies a stable carry in programmin. abode windows noticeably much makes use of C. lots of the video games are stepped forward in C by using fact of its realiability. you may seek in google for loose C tutorials. I propose you to start with studying consle then choose for photos.

2016-12-16 16:07:31 · answer #2 · answered by ? 4 · 0 0

if you want I can send you tokenizer pdf file

2007-01-28 23:40:10 · answer #3 · answered by iyiogrenci 6 · 0 0

fedest.com, questions and answers