• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to print the data based on my condition in Java ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want the dynamic output for a particular condition.
and my condition is :

size =3;
countersize=8;// can be anything based on the user input.

if i got the the countersize as 4 or 5 or 8 for example then my output should be anyone of these 0 or 1 or 2 for a perticular countersize. and the output should be < 3.

**Example1:**

**user Input:** countersize=7 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=5 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=3 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=0 then output=0
**user Input:** countersize=1 then output=1
**user Input:** countersize=2 then output=2
**user Input:** countersize=4 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=9 then output= 0 or 1 or 2 (only one from these)
**Example2 :**
suppose size =2; and countersize=8;// can be anything based on the user input.

**user Input:** countersize=7 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=5 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=3 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=0 then output=0
**user Input:** countersize=1 then output=1
**user Input:** countersize=2 then output=0 or 1 or 2 (only one from these)
**user Input:** countersize=4 then output= 0 or 1 or 2 (only one from these)
**user Input:** countersize=9 then output= 0 or 1 or 2 (only one from these)
similarly if i got the the countersize as 4 or 5 or 8 for example then my output should be anyone of these 0 or 1 for a perticular countersize. and the output should be < 2.
Please help me someone in javacode.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sthitaprajna Jena wrote:if i got the the countersize as 4 or 5 or 8 for example then my output should be anyone of these 0 or 1 or 2 for a perticular countersize. and the output should be < 3.
**Example1:**
**user Input:** countersize=7 then output= 0 or 1 or 2 (only one from these)


I'm afraid your description doesn't make any sense. If countersize=7 and size=3, then what determines whether the output is 0, 1 or 2?

Do you output one of them at random? Or based on the time of day? Or the day of the week? Or is there something else that you haven't told us about?

You need to TellTheDetails (←click); otherwise there's very little we can do to help.

Winston
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Giving an example may help illustrate what needs to be done, but it never DEFINES it.

You need to be able to explain in english, as if you are speaking to a child, what EXACTLY needs to be done. What conditions mean what gets done.

Only after you can do that should you write your code - and you should NOT write a single line before.
 
Sthitaprajna Jena
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry guys, my question was not clear. i fixed it by using random number generation. Thanks
 
Their achilles heel is the noogie! Give them noogies tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic