Q:

Using a While Loop in Java

import java.io.*; 
import java.util.*; 

    public class volumeConeD

{//class
    public static void main (String [] args)
        {//main
            Scanner keyBoard = new Scanner(System.in);//input for keyBoard
        //variables
    double volume;
    double radius;
    double hieght;
    double oneThird = 0.3333;
    double pie = 3.14;
    double yes = 1.0;
    boolean r = true;

try
    {//begin of try
    while(r == true){
    System.out.print("Volume of a Cone... V=1/3(3.14)r^2(h)");
    System.out.println ();
    System.out.println ();

    radius = getRadius(radius);//call to method
    radius = keyBoard.nextDouble ();
System.out.print("Enter a Height      ");
hieght = keyBoard.nextDouble ();
            //math
        volume = oneThird * pie * radius * radius * hieght;
        System.out.printf ("Volume =       " + volume);
                                }//end of try                                           

            catch (Exception Error){
            System.out.println("You entered wrong data");
            }
            System.out.println ();
        System.out.print("Does the user wish to try again?"); 
        System.out.println ();
        System.out.print("Enter 1 to go again OR any other key to end."); 
        yes = keyBoard.nextDouble();
        }//end of while

}//end of main
public static double getRadius(double mRadius)
{
    System.out.print("Enter Radius Squared Number      ");

return mRadius; 
    }
}//end of program

this is my first time posting on this forum, so please excuse how ask...here goes... all i am trying to do with this is repeat this problem under user control using a sentinel method(while loop).  I had it almost working earlier but i kept getting errors about how i defined "r".  Now i get errors about my catch try blocks.  please help.  
volumeConeD.java:35: error: 'catch' without 'try'
            catch (Exception Error){
            ^
volumeConeD.java:35: error: ')' expected
            catch (Exception Error){
                            ^
volumeConeD.java:35: error: not a statement
            catch (Exception Error){
                  ^
volumeConeD.java:35: error: ';' expected
            catch (Exception Error){
                                  ^
volumeConeD.java:19: error: 'try' without 'catch', 'finally' or resource declarations
try
^
5 

A:

You placed your try { outside the while loop, but the corresponding catch is within the while loop.   But must be either outside the loop or inside the loop, together. 
Try placing the try { lines inside the while loop. 
Additionally, it looks like these lines won't work either:
radius = getRadius(radius);//call to method
radius = keyBoard.nextDouble ();

All getRadius does is print out a prompt and return the passed in parameter, radius.   But radius hasn't been initialized yet.   But it looks like nothing is done with it yet anyway.   Rename the method something like promptForRadius, and it doesn't need to take in a parameter or return anything. 
public static void promptForRadius()
{
    System.out.print("Enter Radius Squared Number      ");
}

Then when calling it:
promptForRadius();
// Then you can call this line (unchanged)
radius = keyBoard.nextDouble();

