• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to make the text menu re-appears again in Java  RSS feed

 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone

Im new in JAVA and I just start taking the course fundamentals. Im doing a java program based on method overloading concept. In my program I calculate the areas of circle, square and rectangle. The user has to choose what area to calculate by selecting a number representing the particular area. Once the calculation is done the result is printed to the screen and the menu reappears again to chose what area to calculate. Now I have done most of the parts but Im struggling to do the last point which is after i choose what area to calculate and print the results the menu doesn't appear again to make another calculation. The program ends automatically, I dont want it to end at that point but I dont know how to make the menu appears again to do another calculation. Please help me this is my code

 
Knute Snortum
Sheriff
Posts: 4287
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

I'd put a while or do/while loop around the code and test for some exit key like an empty string.
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute Snortum wrote:Welcome to the Ranch!

I'd put a while or do/while loop around the code and test for some exit key like an empty string.



Thank you. Can you elaborate a little on that?
My understanding is that loops are used in arrays only

 
Carey Brown
Saloon Keeper
Posts: 3328
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Savannah Morrison wrote:
Knute Snortum wrote:Welcome to the Ranch!

I'd put a while or do/while loop around the code and test for some exit key like an empty string.



Thank you. Can you elaborate a little on that?
My understanding is that loops are used in arrays only

Loops are about flow control and have nothing directly to do with arrays.
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
Loops are about flow control and have nothing directly to do with arrays.


Then can you please explain how to implement loops in my program ?
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Savannah, have you discovered teh Oracle tutorials? There's a lesson on The while and do-while Statements
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Burke wrote:Savannah, have you discovered teh Oracle tutorials? There's a lesson on The while and do-while Statements


Thank you. Now I remembered a little from my earlier course of VB. Im kind of familiar of about executing a loop for numbers (integers) to display even/odd or positive/negative values but I never dealt with a loop involving text (string). How can this be done in JAVA?

 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You do not use a loop for numbers or Strings or anything like that. You use a loop to repeat a piece of programming. All you have to do is work out how to get a signal to repeat or stop. I shall let you make your suggestion about how to get the input.

You want to continue when the number is not 4.

By the way: how many inputs do you get if you miss out the break statements in your switch?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, it's Java not JAVA. It's not an acronym.
 
Savannah Morrison
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everyone
I got it
but now i have another problem
help me here http://www.coderanch.com/t/651137/java/java/jGRASP-InputMismatchException-error#3007250
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!