CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2650|Reply: 8

Help Me JAVA coding

[Copy link]
Post time 13-9-2006 05:26 PM | Show all posts |Read mode
anybody can solve it for me...

Write a method that converts its String parameter so that letters are written in block of five characters long.

Example output...

Plain: My Name is Hazlina
Blocked:MyNam eisHa zlina

poning dah pikior.. pakai integer pun tak jadi sorting nye...
nikan pula string...
Reply

Use magic Report


ADVERTISEMENT


Post time 13-9-2006 06:33 PM | Show all posts
Originally posted by azharfcsit at 13-9-2006 05:26 PM
anybody can solve it for me...

Write a method that converts its String parameter so that letters are written in block of five characters long.

Example output...

Plain: My Name is Hazlina
...


aku bagi algorithm je ye.

1) mula2 buang semua whitespace (spacebar, ' ', ataupun \n)
2) initialize empy master string

while ( current string length is greater than 5 characters) {

  potong the first five characters from the current string,
buat new string, append pada satu master string

}

append remainder pada master string

Rate

1

View Rating Log

Reply

Use magic Report

Post time 14-9-2006 09:01 AM | Show all posts
I would do like this:

1. buang semua whitespace or \n
2. initialize empty master string
3. for (i = 1; i <= length of string, i++)
    3.1 print character of string, referred to index i (guna substring)
    3.2 if i mod 5 = 0 then print space

sekian terima kasih :bgrin:

Rate

1

View Rating Log

Reply

Use magic Report

Post time 14-9-2006 09:42 AM | Show all posts
Originally posted by shahnazz at 14-9-2006 09:01 AM
I would do like this:

1. buang semua whitespace or \n
2. initialize empty master string
3. for (i = 1; i <= length of string, i++)
    3.1 print character of string, referred to index i (g ...



yes yang ni pun best gak... tq shahnazz quite elegant. instead of substring bole guna charAt je since dah browse by char. careful with indexing (array offset by 1).
Reply

Use magic Report

Post time 14-9-2006 11:53 AM | Show all posts
careful with indexing (array offset by 1).


of course... :bgrin: tu algorithm aje
Reply

Use magic Report

 Author| Post time 14-9-2006 01:39 PM | Show all posts
orite guys TQ..
i pun dah try wat nih...
very helpful algorithm...
Reply

Use magic Report

Follow Us
Post time 18-12-2006 11:22 PM | Show all posts
aku pulak baru nak belajar j2ee....sungguh complicated :geram:.byk sgt tools yg nak di mix dan match.itu belum lagi setting utk deploy kat appserver.
It's a XML jungle in j2ee...semoga aku dapat cari jalan pulang...:stp:
Reply

Use magic Report

Post time 19-12-2006 10:16 AM | Show all posts

Reply #7 ultra78's post

good experience tu, jangan sia-siakan peluang nak belajar J2EE in a real environment...

good luck :bgrin:
Reply

Use magic Report


ADVERTISEMENT


Post time 19-12-2006 10:49 AM | Show all posts

Reply #8 shahnazz's post

masalahnya nak kena maintain code yg sedia ada dan bukan nak develop benda baru..ejb satu mimpi ngeri..:nyorok:
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT


Forum Hot Topic

 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

28-12-2024 10:55 PM GMT+8 , Processed in 0.068116 second(s), 28 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list