SunQuest
 
           Java Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJava Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old January 16th, 2004, 03:20 PM
singhnx singhnx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Chicago, IL
Posts: 9 singhnx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unable to output number to just one line.

I'm just starting a JAVA class. One of the assignments on the homework is as follows ...

The output result should be:

1, 3, 5, 7, 9, 11, 13, 15, 17, 19 (displayed on only one line)

Here is my attempt at it:
__________________________________________________ _

public class NumberOutput
{
public static void main(String[] args)
{
int i=1, end=19; //declarations and assignments
while (i<end)
{
System.out.println(i + ", ");
i+=2;
}//end of while loop
System.out.println(end);
} //end of main() method
} //end of NumberOutput class
__________________________________________________ _


When I run this, I get the numbers, but just not on one line ...

Any suggestions as to how to proceed would be appreciated.

Thanks for your time.

Navjot

Reply With Quote
  #2  
Old January 16th, 2004, 03:32 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Try using print() instead of println()

Reply With Quote
  #3  
Old January 16th, 2004, 09:14 PM
singhnx singhnx is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: Chicago, IL
Posts: 9 singhnx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for the help. That was the correct command. I'm still waiting for the book to come in, and the print() command would probably have been in there. Have a good one.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJava Development > Unable to output number to just one line.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway