Question: Using C#, The Test class below keeps an integer tally. Its AddFive method adds five to tally, and its Display method displays the current value.

Using C#, The Test class below keeps an integer tally. Its AddFive method adds five to tally, and its Display method displays the current value. The Main method includes a test program. Find and fix any errors in the code below, so that tally is 8 is displayed. using System; namespace Q1 {

class Program {

static void Main(string[] args) {

Test mytest = new Test(3);

mytest.AddFive();

Display();

}

} public class Test {

private int tally;

public Test(int tally)

{

tally = tally;

} public void AddFive()

{

tally += 5;

} public void Display ()

{

Console.WriteLine("tally is {0}", tally);

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!