JAVA PROGRAMMING
Task: Create a class named Eggs. Its main() method holds an integer
variable named numberOfEggs to which you will assign a value entered by
a user at the keyboard.
Create a method to which you pass numberOfEggs. The method displays
the eggs in dozens; for example, 50 eggs is 4 full dozen (with 2 eggs
remaining).
Save the application as Eggs.java
Output:
Source Code:
import java.util.Scanner;
public class Eggs
{
public static void main(String[] args) {
System.out.println("Question: How many Eggs do you have? ");
System.out.print("Input: ");
Scanner read = new Scanner(System.in);
while (!read.hasNextInt()) { //For Integer Verification only
Task: Create a class named Eggs. Its main() method holds an integer
variable named numberOfEggs to which you will assign a value entered by
a user at the keyboard.
Create a method to which you pass numberOfEggs. The method displays
the eggs in dozens; for example, 50 eggs is 4 full dozen (with 2 eggs
remaining).
Save the application as Eggs.java
Output:
Source Code:
import java.util.Scanner;
public class Eggs
{
public static void main(String[] args) {
System.out.println("Question: How many Eggs do you have? ");
System.out.print("Input: ");
Scanner read = new Scanner(System.in);
while (!read.hasNextInt()) { //For Integer Verification only