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

odd numbers

 
john craig
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just started Java and have been given a small problem "create a class to output the values of the first ten odd numbers. Could anyone help please?
JMC
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi John,
Welcome to JavaRanch!
Use a "for" loop. Start at 1 and increment the counter by 2, ten times.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[ partial homework solution removed -ds ]
[ October 30, 2003: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please don't post solutions to homework help requests. 'Round these parts we like to encourage learning and helping others to discover how to solve problems.
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally I don't post any code at all. But lately I have been seeing people posting code right and left - just trying to join the crowd. (And the code wouldn't have compiled.)
And I changed my sig.
[ October 30, 2003: Message edited by: William Barnes ]
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

And I changed my sig.

Thank you. You're a gentleman and a scholar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic