In: Computer Science
Visual C# 2017
Write a program named Eggs that declares four variables of type int to hold the number of eggs produced in a month by each of four chickens, and assign a value to each variable.
Sum the eggs, then display the total in dozens and eggs. For example, if the total number of eggs was 95, the output would be 95 eggs is 7 dozen and 11 eggs.
Note: For final submission ensure that the total number eggs equals 127.
If you have any doubts, please give me comment...
using System;
public class Eggs{
public static void Main(){
int chicken1_eggs = 36;
int chicken2_eggs = 23;
int chicken3_eggs = 28;
int chicken4_eggs = 40;
int total_eggs = chicken1_eggs + chicken2_eggs + chicken3_eggs + chicken4_eggs;
int dozens = total_eggs / 12;
int eggs = total_eggs % 12;
// remove below line if you don't want to print to console
Console.WriteLine("Total number of eggs was {0}", total_eggs);
Console.WriteLine("{0} eggs is {1} dozen and {2} eggs", total_eggs, dozens, eggs);
}
}