I'm having trouble working these last few kinks out my progarm. It would be greatly appreciated if you can help me out from here.
import java.util.Date;
import java.util.Scanner;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import javax.swing.JOptionPane;
import javax.swing.text.BadLocationException;
public class aCircle {
public double circumference(double cRadius)
{
return cRadius;
}
public double Aarea(double aRadius)
{
return aRadius;
}
private double AcessCode(double gCodes)
{
boolean done = false;
while(!done){
//Toaccess the program
JOptionPane.showMessageDialog(null, "User would you\nlike tocontinue?");
Stringinput = JOptionPane.showInputDialog(null, "Enter\nY = YES\nN =No");
if(input.equalsIgnoreCase("Y"))
done = true;
//Exitingthe Progrsm, by selecting "N"
else if(input.equalsIgnoreCase("N"))
{
JOptionPane.showMessageDialog(null, "Acess Terminate");
System.exit(0);
}
JOptionPane.showMessageDialog(null, "Proceed on");
}
return gCodes;
}
/**
* @param args
*/
public static void main(String[] args) throwsFileNotFoundException
{
// TODO Auto-generated methodstub
JOptionPane.showMessageDialog(null, "Today's Date:\n" + newDate());
aCircle myCircle = newaCircle();
//Display the AcessCode
myCircle.AcessCode(1);
//The circumference of thecircle
String input =JOptionPane.showInputDialog(null, "Enter the Radius: ");
double cRadius =Integer.parseInt(input); //Theinput: user enter in.
//Input the circumference ofthe circle
input =JOptionPane.showInputDialog(null, "Enter the Diamter: ");
double cDiameter =Integer.parseInt(input); //Diameter of the circle
double WholeCircle =2*(Math.PI)*(cDiameter); //Calculation for the circumference
//Output thecircumference of the circle
String output =String.format("CIRCUFERENCE: " + "%.3f\n", WholeCircle);
JOptionPane.showMessageDialog(null,output);
myCircle.circumference(cRadius);
//Area of thecircle
input =JOptionPane.showInputDialog(null, "Enter the Radius: ");
double aRadius =Integer.parseInt(input); //Theinput: user enter in.
double area =(Math.PI)*(Math.pow(aRadius, 2));
//Output thearea of the circle
output =String.format("AREA: " + "%.3f\n", area); //Calculation for thearea
JOptionPane.showMessageDialog(null,output);
myCircle.Aarea(aRadius);
System.exit(0);
}
}
The application prompts the user to enter the radius of a circle.
• If the user enters invalid data, the application displays an appropriate error message
and prompts the user again until the user enters valid data.
• When the user enters a valid radius, the application calculates and displays the
circumference and area of the circle to the nearest 2 decimal places.
• The application prompts the user to continue.
• When the user chooses not to continue, the application displays a goodbye message
that indicates the number of Circle objects that were created by the application.