• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

small problem in java

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I am a student and I am trying to write a code that does this

This project will ask a user to input a number for example "please Enter a vaule of N"

and a user types 30 and then the java code will display on the scren like this

0 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

same like that and so and so for if he choose a number more than 30 it will show till the number he chose
and it has to print 10 numbers each line
I don't know how to do nothing seems to be working here
is my code





and this is the out put ( hint I chose number 10 for the input )

that's the out put I got when I run my code




 
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Evan,
Welcome to CodeRanch!

On the second row, think about how you want to figure out the number. It's not 1+0. It's 10+1+0. How could you reflect that in your code? Any ideas?
 
evan yousif
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for replaying, however I am very new in this and no I have no idea!! what you exactly mean
 
Jeanne Boyarsky
author & internet detective
Posts: 42056
926
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's try this another way. This line doesn't do what you want:



When i=0 and j=0, it prints 0 - good
When i=0 and j=1, it prints 1 - good
When i=0 and j=2, it prints 2 - good
When i=1 and j=0, it prints 1 - not good
When i=1 and j=1, it prints 2 - not good
When i=1 and j=2, it prints 3 - not good

For the three "not good" ones, what do you want printed instead? What is it off by?
 
evan yousif
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what you exactly asking! I need the thing to print till the number of the user input example if the user input 10 I want it to display like this

0 1 2 3 4 5 6 7 8 9
10

and it will stop till 10
 
Marshal
Posts: 80140
418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Turn your computer off and use a pencil and paper (and eraser, which is an important tool ‍) to write how you intend to do it. What would the instructions be? When you have those instructions really simple, you will be able to change them into code.
 
evan yousif
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not how you help each other! you guys should show us how to do it sicne you guys are expert! each one of you told me to do something that is out of my question you guys could of just showed me and I was going to know what I did wrong

to those who have same problem as I did I was able to fix it here is the code

 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Evan,
by providing code as a solution is never going to help in the long run.
I am not an Java expert by any means, but I know that you learn the best only by brainstorming.
Coderanch is there to help every one, but not providing complete code as a solution.
I hope experts agree with me.
 
Tapas Chand
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

evan yousif wrote:...you guys should show us how to do it sicne you guys are expert!...


Jeanne and Campbell were actually showing you how to solve the problem.
If you think they are experts, listen to them and follow their suggestions which is the best way to get to the solution.
 
Campbell Ritchie
Marshal
Posts: 80140
418
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't have put it better than Tapas Chand did

Thank you.
 
Tapas Chand
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually thank YOU.
From april 2015 I am following code ranch regularly and learning new things literally everyday.
Learning has never been easier.
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

evan yousif wrote:This is not how you help each other! you guys should show us how to do it sicne(sic) you guys are expert!


I'm sure you've heard the adage "Give a man a fish he eats for a day. Teach a man to fish he eats for a lifetime." We STRONGLY believe that it is better to teach you how to think through a problem than just spoon feeding you answers. There are other sites that will do that.

Please remember that people here are all volunteers, and give you what time, and what help, they choose - no more, and no less.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic