I am a beginner programmer just starting to learn Java. Can someone tell me
what is wrong with this applet?
The output is:
Circumference is 47.1225
Area is 176.70938
Volume is 1767.0938
I don't think that is the correct value of the volume because it is exactly
10 times the area.
What went wrong and also, is there an easier way to square or cube a number?
Thanks,
Josh
//Calculates circumference, area of circle and volume of sphere based on a
radius
import java.awt.*;
import java.applet.App let;
public class Calculations extends Applet {
public void paint(Graphics g) {
float pi = 3.1415f;
float radius = 7.5f;
float circumference = 2.0f * pi * radius;
float area = pi * (radius * radius);
float volume = 4.0f * pi * (radius * radius * radius) / 3;
g.drawString("C ircumference is: " + circumference, 50, 50);
g.drawString("A rea is: " + area, 50, 75);
g.drawString("V olume is: " + volume, 50, 100);
}
}
what is wrong with this applet?
The output is:
Circumference is 47.1225
Area is 176.70938
Volume is 1767.0938
I don't think that is the correct value of the volume because it is exactly
10 times the area.
What went wrong and also, is there an easier way to square or cube a number?
Thanks,
Josh
//Calculates circumference, area of circle and volume of sphere based on a
radius
import java.awt.*;
import java.applet.App let;
public class Calculations extends Applet {
public void paint(Graphics g) {
float pi = 3.1415f;
float radius = 7.5f;
float circumference = 2.0f * pi * radius;
float area = pi * (radius * radius);
float volume = 4.0f * pi * (radius * radius * radius) / 3;
g.drawString("C ircumference is: " + circumference, 50, 50);
g.drawString("A rea is: " + area, 50, 75);
g.drawString("V olume is: " + volume, 50, 100);
}
}
Comment