The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Tags:

Closed Thread
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-10-2007, 04:25 PM
horhora
Posts: n/a
[SOLVED] java program....?

4.(programming) Write a program OddElements that creates an int array containing the odd integers from 51 to 99 and then prints the array elements with 5 elements per line. So the output should be:

51 53 55 57 59
61 63 65 67 69
71 73 75 77 79
81 83 85 87 89
91 93 95 97 99

You must use one for loop to initialize (populate) the array and another for loop to print the elements.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #2 (permalink)  
Old 06-10-2007, 04:27 PM
Helper
Posts: n/a
class OddElements
{
public static void main( String[] a )
{
int [] t = new int[ 50 ];
for( int i =0;i<t.length; i++)
t[ i ] = i+51;

for( int i=0; i<t.length; i++)
{
if ( t[ i ] % 2 == 1)
{
System.out.print( t[ i] + " ");
}
if( i %5 == 0 )
System.out.print( "\n" );
}
}
}

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
  #3 (permalink)  
Old 06-10-2007, 04:27 PM
Geinius's Avatar
Geinius Geinius is offline
Novice
Join Date: Jun 2007
Posts: 6
iTrader: (0)
Geinius is on a distinguished road
Shouldnt this be under homework help?? You are basically saying,
"please do my homework for me.. pls. I posted this in Yahoo! Answers cos its a cheap and easy way to get help.
I copied and pasted the entire question, didnt bother to understand or learn anything, but hope that some fool will answer and post the solution. Even if no one answers i wont lose anything!! Pls help. Im such a loser that i seek help in public forums for solutions to my homework!!! "
int loser=0;
loser= null;

__________________
Powered by Yahoo! Answers
Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Closed Thread


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 01:18 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50