Answer to Question #243802 in C# for mack

Question #243802

Create a class named Eggs. It’s 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 four full dozen (with

2 eggs remaining). Save the application as Eggs.cs


1
Expert's answer
2021-09-28T13:11:14-0400
using System;
using System.IO;
using System.Collections.Generic;


namespace App{
    class Eggs
    {
        static void Main(string[] args)
        {
            Console.Write("Enter number of eggs: ");
            int numberOfEggs = int.Parse(Console.ReadLine());
            displayEggsInDozens(numberOfEggs);




            Console.ReadLine();
        }


        static void displayEggsInDozens(int numberOfEggs)
        {
            int dozen = numberOfEggs / 12;
            Console.Write("{0} eggs is {1} full dozen", numberOfEggs, dozen);
            int remaining = numberOfEggs % 12;
            if (remaining != 0)
            {
                Console.Write(" (with {0} eggs remaining).", remaining);
            }
            Console.WriteLine();
        }


    }
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS