Help With Java Program(s): Beginner

Joined
Oct 6, 2012
Messages
1
Reaction score
0
Hi, I just started college recently and Java is on the course. Unfortunately I am not yet very adept at Java and I'm having difficulty with a simple program.
The program is supposed to count the amount of boxes needed to deliver eggs by the dozen, and to calculate the number of leftovers which wont fill a box.
If anyone could help me I would be very appreciative.

Eggs.java
/*
*EggBoxes.java
*@author Seán
*4th October 2012
*/

public class Eggs{
//declare data members
private int eggs;
private int boxes;
private int leftovers;
private int totalBoxes;
private int totalLeftovers;

//constructor
public Eggs(){
eggs = 0;
boxes = 0;
leftovers = 0;
}

//set method - one for every input variable
public void setEggs(int eggs){
this.eggs = eggs;
}

//compute method
public void computeBoxes(){
boxes = eggs / 12;
totalBoxes = boxes;
}

public void computeLeftovers(){
leftovers = eggs - (eggs / 12);
totalLeftovers = leftovers;
}

//get method(s)
public int getBoxes(){
return boxes;
}

public int getLeftovers(){
return leftovers;

}
}

EggsApp.java
/*
*EggsApp.java
*@author Seán
*4th October 2012
*/

import java.util.Scanner;
public class EggsApp{
public static void main(String args[]){
//declare variables
int eggs, boxes, leftovers;

//declare objects
Scanner keyboard;
Eggs myEggs;

//create objects
keyboard = new Scanner(System.in);
myEggs = new Eggs();

//input
System.out.println("Please enter the amount of eggs you have");
eggs = keyboard.nextInt();
myEggs.setEggs(eggs);

//process
myEggs.computeBoxes();
myEggs.computeLeftovers();

//output
Boxes = myEggs.getTotalBoxes;
System.out.println("The number of boxes required is"+boxes);
Leftovers = myEggs.getTotalLeftovers;
System.out.println("The number of eggs leftover is"+leftovers);

}

}

Thank you in advance.
 
Joined
Oct 8, 2012
Messages
5
Reaction score
0
I want to listen to music on my phone, I have no idea what to do please help

Music on my phone? How do I do this? I have no idea what to do - please help a person who knows nothing about phones/computers or any thing like that! My kids have always looked after these things for me but they have grown up and left home so it's time to learn for my self.
 
Joined
Oct 8, 2012
Messages
5
Reaction score
0
I do I read my reply, if I have one??

Please will some one tell me how to work this bloody phone, I've been trying now for hours, how do I find my reply.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,979
Messages
2,570,184
Members
46,722
Latest member
NelsonHeil

Latest Threads

Top