title: Printing out variables from different methods in java?
body: <p>I have to use different methods for this code, no java shortcuts!
  Here is my code:</p>
  
  <pre><code>import java.io.*; 
  
  import java.util.Scanner; 
  
  public class pg3a { 
  
  public static void main(String[] args) throws IOException { 
  
     Scanner keyboard = new Scanner(System.in); 
  
     String hex; 
     char choice = 'y'; 
     boolean isValid = false; 
     do { 
        switch (choice) { 
     case 'y': 
        System.out.print("Do you want to enter a hexadecimal number? "); 
        System.out.print("y or n?: "); 
        choice = keyboard.next().charAt(0); 
  
        System.out.print("Enter a hexadecimal number: #"); 
        hex = keyboard.next(); 
        hex = hex.toUpperCase(); 
        int hexLength = hex.length(); 
        isValid = valid(hex); 
          if (isValid) { 
              System.out.println(hex + " is valid and equal to" + convert(hex)); 
          } 
          else { 
             System.out.println(hex + " is invalid."); 
         } 
       case 'n': 
         System.out.println("quit"); 
        } 
        }while (choice != 'n'); 
  } 
  
  public static boolean valid (String validString) { 
  
    int a = 0; 
    if (validString.charAt(0) == '-') { 
    a = 1; 
  } 
   for (int i=a; i&lt; validString.length(); i++) { 
      if (!((validString.charAt(i) &gt;= 'a' &amp;&amp; validString.charAt(i) &lt;= 'f')|| (validString.charAt(i) &gt;= 0 &amp;&amp; validString.charAt(i) &lt;= 9))) 
  { 
  return false; 
  } 
  } 
  return true; 
  } 
  </code></pre>
  
  <p>How can I make it so that after the program checks all the parameters for the hexadecimal number and calculates what it should be in decimal form, it prints out that the hexadecimal number is valid and then what the decimal number is?? </p>
  
  <p>Also how can I make it a loop that ends with either ^z or ^d to end the program? </p>