Answer to Question #340828 in C# for SITHEMBELE

Question #340828

Write an application that displays revenue generated for exercise classes at the Tappan Gym. The gym offers two types of exercise classes, zumba and spinning, six days per week, four times per day. Zumba is offered at 1, 3, 5, and 7 p.m.; spinning is offered at 2, 4, 6, and 8 p.m. When attendees sign up, they agree to pay $4.00 per class for zumba and $5.00 for spinning. Produce a table displaying the number of attendees per time slot. Display a row and column of totals showing the total number of attendees by day and also time period. Also include a column showing the revenue generated each day and the overall revenue per type of exercise. Do a compile-time initialization of your data structures using data from the following table.


1
Expert's answer
2022-05-14T16:39:33-0400
internal class Program
    {
        class TappanGym
        {


            public Dictionary<int, int> Zumba = new Dictionary<int, int>()
            {
                [1] = 0,
                [3] = 0,
                [5] = 0,
                [7] = 0,
            };
            public Dictionary<int, int> Spinning = new Dictionary<int, int>()
            {
                [2] = 0,
                [4] = 0,
                [6] = 0,
                [8] = 0,
            };


            public int PriceZumba = 4;
            public int PriceSpinning = 5;


            public TappanGym(int[] zumba, int[] spinning)
            {
                int current = 1;
                for (int i = 0; i < zumba.Length; i++)
                {
                    Zumba[current] = zumba[i];
                    current += 2;
                }


                current = 2;
                for (int i = 0; i < spinning.Length; i++)
                {
                    Spinning[current] = spinning[i];
                    current += 2;
                }
            }
            public override string ToString()
            {
                string zumbaString = "";
                foreach (var zumba in Zumba)
                {
                    zumbaString += $"{zumba.Key}p.m. - {zumba.Value}\n";
                }


                string spinningString = "";
                foreach (var spinning in Spinning)
                {
                    spinningString += $"{spinning.Key}p.m. - {spinning.Value}\n";
                }


                return $"Zumba\n{zumbaString}\nSpinning\n{spinningString}\n" +
                    $"Total visitors:{Spinning.Values.Sum()+Zumba.Values.Sum()}\n" +
                    $"Income per day:{Spinning.Values.Sum()*PriceSpinning+ Zumba.Values.Sum() * PriceZumba} , Income per Zumba:{Zumba.Values.Sum() * PriceZumba}, Income per Spinning:{Spinning.Values.Sum() * PriceSpinning} ";
            }
        }


        static void Main(string[] args)
        {
            Dictionary<DateTime, TappanGym> Gym = new Dictionary<DateTime, TappanGym>()
            {
               { new DateTime(2022, 2, 14), new TappanGym(new int[] { 1, 5, 6, 7 }, new int[] { 5, 9, 8, 10 }) },
               { new DateTime(2022, 3, 14), new TappanGym(new int[] { 1, 8, 5, 30 }, new int[] { 2, 30, 8, 7 }) }
            };
            foreach (var gym in Gym)
            {
                Console.WriteLine($"{gym.Key.ToShortDateString()}");
                Console.WriteLine(gym.Value);
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }

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
New on Blog
APPROVED BY CLIENTS