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
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();
}
}
}
Comments
Leave a comment