Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java Help
#1
A friend is having a problem.

Quote:
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;
}

}
"Its supposed to use Math.pow to find circumference,radius,and diamete"

In his own words. I know nothing about Java, so, i can't say, can you?
Reply


Messages In This Thread
Java Help - by Gone - 01-19-2010, 06:38 PM
RE: Java Help - by Project Evolution - 01-20-2010, 07:37 PM
RE: Java Help - by Qkyrie - 01-21-2010, 06:05 AM
RE: Java Help - by Gone - 01-21-2010, 02:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  why java haphazard 8 1,751 12-12-2011, 03:23 AM
Last Post: RDCA
  Need Java help from java expert. Blazin 2 2,091 09-07-2011, 02:43 PM
Last Post: AceInfinity
  Java help php 1 1,026 04-06-2010, 06:41 AM
Last Post: php
  Java Problem for real java programmer Testgamma1 10 5,135 03-14-2010, 09:08 AM
Last Post: uber1337
  How do i get java Mozz 4 1,571 02-13-2010, 12:29 PM
Last Post: Mozz

Forum Jump:


Users browsing this thread: 1 Guest(s)