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.
1
Expert's answer
2012-09-04T11:20:35-0400
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);
Comments
Leave a comment