Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Arrays C# Console and Windows Programming usina Visual C#.Net class Mp3Chart string[] topTen const int MAX = 5; // define a string array called

C# Arrays

image text in transcribed

image text in transcribed

C# Console and Windows Programming usina Visual C#.Net class Mp3Chart string[] topTen const int MAX = 5; // define a string array called top Ten public static void Main( // program starts executing here Mp3Chart myChart - new Mp3Chart); myChart.run( // create new object /call its run method public Mp3Chart0) // constructor topTen - new string[MAX II create a new array of correct size topTeno "Revolution"; initialise the array values topTen[1] = "Mera Dil Tuta Hain"; topTen[2] "CandyMan'" topTen[3] "Ruby Tuesday" topTen[4] = "Old Man"; public void run() showMusicList); getVotes(); public void showMusicList) Console.Clear); Console.WriteLine("ItMusic List"); Console.WriteLine("t); for (int i-o; i MAX, i++) Console.WriteLine("tSong" +(i + 1)+ "is " + topTen[il): public void getVotes) int userVote; Console.WriteLine("ItSelect your favourite Song") Console.WriteLine("" Console.Write("ItChoose 1 5:"); userVote Convert.Tolnt32(Console.ReadLine) Iend of Mp3Chart class 5.2 MP3 Chart Voter Look at project Task6_2.csproj. Compile and run it. The program presents you with a list of song tracks and you have to vote for your favourite. Of course it is far from finished Examine the existing code on the next page modify the program to complete these tasks: Task 5.2 The program has to keep a count of all the votes for each song track. 1. Create a new integer array called votes that will be used to count the votes for each track 2. Now inside the getVotes() method you need to add one to the appropriate vote in the votes array. There are several ways of doing this. e.g. if the vote was for track 5 then add 1 to votes[4] (remember arrays start counting from 0) 3. Get the program to repeat for many voters by using a loop inside the run) method 4. Add another method called show Votes(0 which displays all the vote counts like this: MP3 Track Votes Track 1 hadvotes Track 2 had

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions