Q:

Modify the Eggs program to create a new one named EggsInteractive that prompts the user for and accepts a number of eggs for each chicken

0

Modify the Eggs program to create a new one named EggsInteractive that prompts the user for and accepts a number of eggs for each chicken.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace EggsInteractive
{
    class EggsInteractive
    {
        static void Main(string[] args)
        {
            WriteLine("EggsInteractive");

            int eggs1 = 0;
            int eggs2 = 0;
            int eggs3 = 0;
            int eggs4 = 0;
            int calculatedSum = 0;
            int calculatedDozen = 0;
            int calculatedLeftover = 0;

            //skip error checking
            Write("chicken1 eggs:");
            eggs1 = int.Parse(ReadLine());
            Write("chicken2 eggs:");
            eggs2 = int.Parse(ReadLine());
            Write("chicken3 eggs:");
            eggs3 = int.Parse(ReadLine());
            Write("chicken4 eggs:");
            eggs4 = int.Parse(ReadLine());

            calculatedSum = eggs1 + eggs2 + eggs3 + eggs4;

            calculatedDozen = calculatedSum / 12;
            calculatedLeftover = calculatedSum % 12;

            WriteLine("{0} eggs comes to {1} dozen and {2} eggs.", calculatedSum, calculatedDozen, calculatedLeftover);

            WriteLine("--End--");
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now