• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

couldnt find place for break;

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


code like that,
For example, if n = 7, then the program should output 1 2 2 3 3 3 4.(there is 7 okey. ) but problem is, ıt prints whole sequence for all numbers.yes i tried several break and boolean false.
 
Sheriff
Posts: 17124
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

It's not very clear what your question is. It's not clear what the program is supposed to do either.

Two questions:

1. Is the goal of this exercise to learn how to use the break statement?

2. Given a number, N, are you supposed to print up to N numbers of the sequence 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 . . . ?
 
umit morris
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Welcome to the Ranch!

It's not very clear what your question is. It's not clear what the program is supposed to do either.

Two questions:

1. Is the goal of this exercise to learn how to use the break statement?

2. Given a number, N, are you supposed to print up to N numbers of the sequence 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 . . . ?



Well,i I wrote quickly sorry.
Thanks for the quick response. question was For example, if input = 7, then the program should output 1 2 2 3 3 3 4.
n(input): the number of the elements of the sequence the program should print.
but my outpout is 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7  i couldnt find where should i put the break statements.
 
Junilu Lacar
Sheriff
Posts: 17124
298
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you understand why it's printing the entire sequence? Can you express the condition for stopping the printing out of numbers in the sequence?

You say you couldn't find where... so what have you tried so far?
 
umit morris
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Do you understand why it's printing the entire sequence? Can you express the condition for stopping the printing out of numbers in the sequence?

You say you couldn't find where... so what have you tried so far?


Yes i got i why its printing whole sequence.exercise under the break statement topic after for loop topic. I have tried the stop inner loop with break; when n teached 7,i tried even stop outer loop after that i just gave up
 
Saloon Keeper
Posts: 9563
79
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to actually show us what you tried so that we have something to work with.
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic