Answer to Question #14002 in Java | JSP | JSF for Sheila Saran

Question #14002
Assume you have N eggs and you pack them 12 to a carton. Write a program that determines how many egg cartons you need and how many eggs will be left over. The output should be formatted as follows: Total number of eggs is ___ Number of cartons needed is ___ Number of eggs left over is ___ Run your program for N = 11 and N = 37.
Expert's answer
package task14002;

import java.util.Scanner;

public class main
{

public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

System.out.println("Enter number of eegs: ");
int eggs = Integer.parseInt(in.nextLine());

final int numb=12;

int cartons=eggs/numb;

int left=eggs%numb;

System.out.println("Total number of eggs is "+eggs);
System.out.println("Number of cartons needed is "+cartons);
System.out.println("Number of eggs left over is "+left);

}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal