01-19-2010, 06:38 PM
A friend is having a problem.
In his own words. I know nothing about Java, so, i can't say, can you?
Quote:"Its supposed to use Math.pow to find circumference,radius,and diamete"Code:import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DescribingThePlanets2
{
public static void main(String args[])
{
int Planet;
int answerSquare;
int answerCube;
int num1;
String numOne =
JOptionPane.showInputDialog("Enter a number to be squared");
num1 = Integer.parseInt(numOne);
answerSquare = square(num1);
answerCube = cube(num1);
System.out.println("The squared value returned from the method is " + answerSquare);
System.out.println("The cubed value returned from the method is " + answerCube);
String strPlanet;
strPlanet = JOptionPane.showInputDialog("Enter a Number of a Planet Please ");
Planet = Integer.parseInt(strPlanet);
if(Planet <= 1)
{
System.out.println("Mercury");
}
else if(Planet <= 2)
{
System.out.println("Venus");
}
else if(Planet <= 3)
{
System.out.println("Earth");
}
else if(Planet <= 4)
{
System.out.println("Mars");
}
else if(Planet <= 5)
{
System.out.println("Jupiter");
}
else if(Planet <= 6)
{
System.out.println("Saturn");
}
else if(Planet <= 7)
{
System.out.println("Uranus");
}
else if(Planet <= 8)8)
{
System.out.println("Neptune");
}
else if(Planet <= 9)
{
System.out.println("Pluto");
}
}
public static int square(int number) //method declaration
{
return number number;
}
public static int cube(int number)
{
return number number * number;
}
}
In his own words. I know nothing about Java, so, i can't say, can you?