I am taking an online java programming class this quarter and the book I have just does not do a good job of explaining anything! The more I read it, the more confused I become!

Can someone refer me to an article or site that explains creating methods in terms that are easy to understand? I'll post a copy of my assignment below so you can have an idea of what Im looking for..

Create a class named Eggs. Its main() method holds an integer vaiable named numberOfEggs to which you will assign a value. Create a method to which you pass numberOfEggs.
The method displays the eggs in dozens; for example, 50 eggs is 4 full dozen with two left over.

Save the program as Eggs.java.

You may want to review some of the material in the "Starting Java" thread that is stickied at the top of the forum for basics.

What part of the assignment do you not understand? What do you have so far?

I am really confused about the whole deal. This is only the second week of the class and I haven't been able to grasp the idea of any of it thus far. :(
I dont understand what it means by "passing"

This is what I have so far.

public class Eggs 
{

public static void main(String[] args) 
{
    int numberofEggs = 25;

        System.out.println("25 eggs are two full dozen plus one");

        }
}

I'll go read though that thread.. thanks

They mean make a method that has a parameter, numberOfEggs, which is an integer.

try to read in elliot coffman book in java its very simple to understand
public class eggs
{public static void main(String args [])
{
int NumberOfEggs =25;
System.out.print("Full dozen"+ duzen(NumberOfEggs ) );
}
public int duzen( int x)
{return x/12; }
}

it is OK the beginning always be like that

you may want to try read this, I had when I was in my earlier weeks

http://www.freejavaguide.com/corejava.htm

also the Deitel and Deitel resource are worthy to read
if you have visited that link and not helping plz let me know, and wish you can send what sites you have tried so far,

passing means that to send the parameter the method would use in its calculation, sending them when you call the method,

hope this helps, good luck

Thanks everyone. I will look over the link and see if it helps.

I dont understand what it means by "passing"

'passing' here is about the same as in sports: one guy has the ball, he 'passes' it to another guy, now that other guy has controle over it.

// class that uses an object or class
Sports.showPass("this ball");

// other class -> Sports.java
public void showPass(String pass){
// the String-object 'pass' is passed on to the method
System.out.println("the first player passed " + pass);
}
commented: I like that explanation +18

'passing' here is about the same as in sports: one guy has the ball, he 'passes' it to another guy, now that other guy has controle over it.

// class that uses an object or class
Sports.showPass("this ball");

// other class -> Sports.java
public void showPass(String pass){
// the String-object 'pass' is passed on to the method
System.out.println("the first player passed " + pass);
}

Thanks! Those are terms I can understand.. LOL I will be working on this all day today - I have three assignments and an application test all due today! EEEKKK! I have been reading the same chapter in my textbook since Sunday trying to understand this stuff.

Well, this is what I have at this point and its loaded with errors.. I changed my number of eggs to 13 hoping it would make it easier for me to code the computation

public class Eggs 

   {
    public static void main(String[] args) 
    {
        numberOfEggs();
    }

public static void numberOfEggs;

    System.out.println ("13 eggs are one full dozen + remaining")

// Kelly Bowden - Assignment # 3, Chapter 3, February 3, 2009
        }
}


public class Test 

{
public static void main(String[] args) 
{
   System.out.println("Calling method from another class"); 
    Eggs.numberOfEggs();
    // Kelly Bowden - Assignment # 3, Chapter 3, February 3, 2009
        }
}

public class Eggs2 

{

    public static void main(String[] args) 
    {
    int dozen = 12;
    int eggs = 13;  
        numberOfEggs();
    eggs - dozen = remaining;

    }

public static void numberOfEggs;

    System.out.println ("13 eggs are one full dozen + remaining")


    // Kelly Bowden - Assignment # 3, Chapter 3, February 3, 2009
        }
}

public class Eggs2
{
public static void main(String[] args) {
int dozen = 12;
int eggs = 13;
numberOfEggs();
eggs - dozen = remaining;
}

public static void numberOfEggs;

System.out.println ("13 eggs are one full dozen + remaining")


// Kelly Bowden - Assignment # 3, Chapter 3, February 3, 2009
}
}

I'm not really sure what you're trying to do in here, but there are indeed a number of serious errors in here.

public class Eggs2 
{
    public static void main(String[] args)  {
	int dozen = 12;
	int eggs = 13;	
//        numberOfEggs();
//	eggs - dozen = remaining;
       int remaining = eggs - dozen;
       numberOfEggs(remaining);
    }

//public static void numberOfEggs;
public static void numberOfEggs(int remaining){ 

	//System.out.println ("13 eggs are one full dozen + remaining")
	System.out.println("13 eggs are one full dozen + remaining");
      // what I think you want to do here is:
       System.out.println("13 eggs are one full dozen + " + remaining);

	// Kelly Bowden - Assignment # 3, Chapter 3, February 3, 2009
        }
}

Look at a piece of example code. . you're attempting to use numberOfEggs as if its a method, but you have not declared it w/ a method header & method body.

Do you have this solved and turned in yet. Are you still stuck?

This is how i did mine like that:

import java.util.Scanner;
public class Eggs
{
     public static void main(String args [])
      {

        int eggs;
       int numberOfEggs;
        int dozen = 12; 

        Scanner inputDevice = new Scanner(System.in);
        System.out.print("Please enter the number of eggs ...");
       eggs = inputDevice.nextInt();
      System.out.print("Total eggs " + eggs*dozen);

       }
} 

hope it helps.

so i am trying to figure out a code to use in java and i cant seam to get it right. i am trying to use a simple addition function. i feel so stupid!!!!

and what's your point?
you don't show what code it is you 're looking into, you don't say what problems you 're encountering, you're not even taking the time to create a new thread for your questions (if any) ..
not really the most valuable post on this forum

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.