I need to design and code a Java program that calculates and prints the (D) diameter, the (C) circumference, or the (A) area of a circle, given the radius. The program inputs two data items: the calculation needed, and the radius of the circle. The program should continue to ask the user for values until the user enters 'Q' as the calculation type. The program should echo print the input data and prompt appropriately. Label the output and format to two decimal places. The 'N' option is for a new circle. Is there anyone that can help me??

Example:

Enter the calculation type (A, C, D, N, Q):

N

New circle, Enter radius:

6.75

Enter the calculation type (A, C, D, N, Q):

A

The area of a circle with a radius of 6.75 is 143.14

D

The diameter of a circle with a radius of 6.75 is 13.50

Enter the calculation type (A, C, D, N, Q):

Q

Thank You.

I am new to Java and have no idea how to write the code for this to work right. Is there anyone that will take pity on a newbie? This is what I have so far. But I can't get it to work.

import java.util.Scanner; // uses class Scanner

public class circleCalculator
{
public static void main(String args[])





// create Scanner to obtain input
// prompt for input
{
Scanner input = new Scanner( System.in );
char option = '?'; // input character
String instring; // string
int radius = 0; // radius entered by user
int area = 0;
int circumference = 0;
int diameter = 0;

do
{

System.out.println( "Enter calculation type (n = new, a = area, c = circumference, d = diameter, q = quit): " );
instring = input.next();
option = instring.charAt(0);

if ( option == 'N' || option == 'n' )
{
System.out.println( "Enter the radius of the circle: " );
instring = input.next();
radius = instring.Int();
} // end if statement
while ( radius > 0 )
{
if ( option == 'A' || option == 'a' )
area = (double) (radius * radius) * 3.14159;
System.out.printf( "The area of the circle is: %f.2\n", area );

if ( option = 'C' || option = 'c' )
circumference = (2 * 3.14159) * (double) radius;
System.out.printf( "The area of the circle is: %f.2\n", circumference );

if ( option == 'D' || option == 'd' )
diameter = 2 * (double) radius;
System.out.printf( "The diameter of the circle is: %f.2\n", diameter );
} // end while statement

} while ( option == 'Q' && option == 'q' );
System.out.println( "Thank You!" );

} // end main