Welcome to Dream.In.Code
Become a Java Expert!

Join 149,520 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,404 people online right now. Registration is fast and FREE... Join Now!




Exponent

 
Reply to this topicStart new topic

Exponent

snugglesmocha
24 May, 2007 - 02:30 PM
Post #1

New D.I.C Head
*

Joined: 14 Apr, 2007
Posts: 28


My Contributions
I am to create a main method that holds an integer value and pass the value to a method that squares the nubmer and a method that cubes the number.
Here is what I have so far:
public class Exponent
{
public static void main(String[] args)
{
int = 2;
square = twicethenumber;
cubed = threetimesthenumber;
}
pulbic static int square(2 * twictethenumber)
{
System.out.println("The square is" + (2 * twicethenumber));
}
public static int cubed(2 * threetimesthenumber)
{
System.out.println(The cube is" + (2 * threetimesthenumber));
}
}
The is something wrong with this. Any help??

User is offlineProfile CardPM
+Quote Post

William_Wilson
RE: Exponent
24 May, 2007 - 02:54 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 4,101



Thanked: 25 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
there are many, many mistakes here:
int = 2;
this is not valid, you provide a type and a value, but no variable name, an acceptable replacement could be:
int i = 2;, though i am unsure why this line is there.

CODE

square = twicethenumber;
cubed = threetimesthenumber;

I don't know what this is... none of these 4 items are defined anywhere, so the assignment is not allowed, nor is there use at all. Are these variables, methods..?
I assume you were looking for something like:
CODE

int square = square(i);
int cubed = cubed(i);


your logic within your methods is wrong as well:
square: (you spelled public as pulbic in this declaration as well)
CODE

public static int square(int number)
{
     System.out.println("The square is " + number*number);
}

I'll leave it to you, to fix your cubed method.
User is offlineProfile CardPM
+Quote Post

Ryan747
RE: Exponent
24 May, 2007 - 09:57 PM
Post #3

New D.I.C Head
*

Joined: 16 Oct, 2006
Posts: 26


My Contributions
CODE

public static int square(2 * twictethenumber)
{
   System.out.println("The square is" + (2 * twicethenumber));
}
public static int cubed(2 * threetimesthenumber)
{
    System.out.println(The cube is" + (2 * threetimesthenumber));
}


On thing about this code... It doesn't return an int value....
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:25PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month