Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I ONLY NEED PART B OF THIS QUESTION a. Write a program named Eggs that declares

ID: 3662083 • Letter: I

Question

I ONLY NEED PART B OF THIS QUESTION

a. Write a program named Eggs that declares four variables 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, a total of 127 eggs is 10 dozen and 7 eggs.

I have part A which is below and just need part B:

01

using System;

02

public class Eggs

03

{

04

public static void Main()

05

{

06

string egg1AsString,

07

egg2AsString,

08

egg3AsString,

09

egg4AsString;

10

11

Int32 egg1,

12

egg2,

13

egg3,

14

egg4,

15

total,

16

total2,

17

total3;

18

19

Console.WriteLine("Enter first chickens eggs");

20

egg1AsString = Console.ReadLine();

21

egg1 = Convert.ToInt32(egg1AsString);

22

Console.WriteLine("Enter second chickens eggs");

23

egg2AsString = Console.ReadLine();

24

egg2 = Convert.ToInt32(egg2AsString);

25

Console.WriteLine("Enter third chickens eggs");

26

egg3AsString = Console.ReadLine();

27

egg3 = Convert.ToInt32(egg3AsString);

28

Console.WriteLine("Enter fourth chickens eggs");

29

egg4AsString = Console.ReadLine();

30

egg4 = Convert.ToInt32(egg4AsString);

31

32

total = egg1 + egg2 + egg3 + egg4;

33

total2 = total / 12;

34

total3 = total2 %12;

35

Console.WriteLine("Total eggs is {0} dozen and {1} eggs.", total2, total3);

36

Console.ReadLine();

37

}

38

}

b. 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.

Explanation / Answer

The following program calculates the number of dozens and remainder eggs once a user inputs the number of eggs for each of the 4 chickens.

using system

namespace EggsInteractive

{

OUTPUT:

This program will show the number of eggs produced by 4 chickens in one month in terms of dozens and the remaining eggs after taking an input from the user for the number of eggs from each chicken

Please enter the Egg Numbers for Chicken 1:20

Chicken1 has Layed 20 Eggs

Please enter the Egg Numbers for Chicken 2:40

Chicken2 has Layed 40 Eggs

Please enter the Egg Numbers for Chicken 3:40

Chicken3 has Layed 40 Eggs

Please enter the Egg Numbers for Chicken 3:27

Chicken4 has Layed 27 Eggs

Total number of eggs is 127

The Total Dozens of eggs is 10 with remainder 7