View Single Post
  #1 (permalink)  
Old 07-18-2007, 09:23 PM
silvia silvia is offline
Member
 
Join Date: Jul 2007
Posts: 35
silvia is on a distinguished road
Help me: loops in java
I have a very simple exercise. I am trying to call several methods from the main. I can call the method and the java input works but I can't get it to go back to the main after a valid selection has been made.
Can someone steer me in the right direction please?

Code:
class sampledata { public static final void main (String[] argv) { System.out.println("I am going to ask you some questions. Please answer using capital letters for any A,B,C choices. Thankyou."); System.out.println("Do you live in the "); options1(); question2(); }//end main static void options1() { System.out.println("(A) Northern Hemisphere"); System.out.println("(B) Southern Hemisphere"); System.out.println("(C) neither of the above"); int count = 2; do { KeyboardReader kb = new KeyboardReader(); char choose; choose = kb.getChar(); switch (choose) { case 'A': System.out.println("Ahah, so it is Spring right now for you."); break; case 'B': System.out.println("Like me you are approaching Winter. I hope it is mild for you."); break; case 'C': System.out.println("Hmmm, surely you know what hemisphere you live in. Try another selection."); break; default: System.out.println("That was not a valid selection"); } }while (count>1); } static void question2() { System.out.println("Question 2 not yet prepared. Come back soon."); } }
Thanks
Reply With Quote
Sponsored Links