Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   Help With Java Program(s): Beginner (http://www.velocityreviews.com/forums/t953128-help-with-java-program-s-beginner.html)

 Q1uic 10-06-2012 10:07 PM

Help With Java Program(s): Beginner

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);

}

}

 1968 10-08-2012 05:00 PM

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.

 1968 10-08-2012 05:46 PM