Hello i have my code done but dont have access to my Java program. Can somone in
ID: 3647513 • Letter: H
Question
Hello i have my code done but dont have access to my Java program. Can somone input this in the program then show a screenshot of of the output? I do not have my computer currently so i really need the screenshot please and thank youwhile(goodInput == true){
//try/catch all that good stuff
}
if you cant get it to work let me know I post it ;)
So I did this in a very simple manner here is the circle class:
public class Circle1
{
public static double circumference(double radius)
{
//circumference = pie * diameter
double diameter, circumference;
diameter = 2*radius;
circumference = Math.PI * diameter;
return circumference;
}
public static double area(double radius)
{
//area = pie*r^2
double area;
radius = Math.pow(radius, 2);
area = Math.PI * radius;
return area;
}
}
Here is the circleTest class
import java.text.DecimalFormat;
import java.text.NumberFormat;
import javax.swing.JOptionPane;
public class CircleTest extends Circle1
{
public static void main(String[] a)
{
double radius, C, A;
String temp = JOptionPane.showInputDialog(null, "Enter the radius of the Circle");
try{
radius = Double.parseDouble(temp);//parse to double
//create the object
Circle1 circle = new Circle1();
//do the calcs
C = circle.circumference(radius);
A = circle.area(radius);
//create the format
NumberFormat f = new DecimalFormat("0.000");
//show the output
JOptionPane.showMessageDialog(null, "The circumference is: " + f.format(C) + " " + "The Area is: " + f.format(A));
}catch(Exception e){
System.out.println("That is not a number");
}
}
Explanation / Answer
online java compiler is at www.vim.org/scripts/script.php?script_id=245;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.