473,320 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Not sure how to do something

20
ok my method asks to the user to enter a lower boundary and an upper boundary. If their upper boundary number is lower than the lower boundary number then it need to print out something like "Your upper boundary cannot be smaller than your lower boundary" and then start asking for new numbers again. Im guessing some kind of loop but im not sure how to set it up. Heres what i have in the method so far.

Expand|Select|Wrap|Line Numbers
  1. public void getBoundaries(); // get lower and upper boundaries
  2. {
  3.  
  4. Scanner in = new Scanner ( System.in );
  5. int value = 0, value1 = 0;
  6.  
  7.  do
  8.  {
  9.  System.out.print ( "Please enter the lower boundary (between 1 and 50000): " );
  10.  value = in.nextInt();
  11.  }
  12.  while ( ( value < 1 ) || ( value > 50000 ) );
  13.  
  14.  do
  15.  {
  16.  System.out.print ( "Please enter the upper boundary (between 1 and 50000): " );
  17.  value = in.nextInt();
  18.  }
  19.  while ( ( value1 < 1 ) || ( value1 > 50000 ) );
  20.  
  21. }
Nov 26 '08 #1
1 1090
jkmyoung
2,057 Expert 2GB
Can't you just put a do-while around the entire thing?
Nov 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: droog | last post by:
hi group! I am new to PHP and so far managed to find my answers by searching this group instead of posting repeating questions, but I don't know what to search for to get answer to this...
4
by: Oliver Spiesshofer | last post by:
Hi, I want to make a standard-function that handles "Are you sure"-type questions. In my idea it should look something like this: <code> Function deleteitem($item) {
4
by: Hywel | last post by:
I'm having trouble with a bit of form to mail for a site I work on an was wondering if anyone could point out where I've gone wrong. <% Dim t1name,t1,t2name,t2,t3name,t3,t4name,t4,t5name,t5 ...
3
by: jj | last post by:
example is I'm finding the max number within a certain criteria, and then adding one to that. However, most IDs are something like K00001 or R00223 So I want the next ID to be either K00002 or...
4
by: Will | last post by:
Hello all I'm not sure how to word this, which is one reason why I couldn't find anything on Google to help me, so please bear with me as I try to explain myself... I am trying to create a...
7
by: Nathan Sokalski | last post by:
I have a form that allows the user to upload a file. Even though <input type="file" runat="server"> is intended to have the user choose the file using the browse button, it still allows them to...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
9
by: Chad | last post by:
The input file is: Params 1 2 3 4 5 6,7 Data 1,1
1
by: Romanian | last post by:
Hey all, I'm not sure if this would require JavaScript or something else. I want to log into my gMail account with this little program, and then be able to browse links which can be manually...
3
by: lanoak | last post by:
Hi, new hear and just starting out in CSS so I'm sure this is something simple. I'm trying to build a horizontal menu bar with 5 different headings: home, process, policies and proceedures,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.