Create a console application. solved

Create a console application. solved

1. Create a console application.

2. Add a public class called compute_product.

3. In compute_product declare two private fields (class variables) named value1 and value2.

4. For field (class variable) value2 create a public property named Value2 and implement the get and set.

5. Add a constructor to assign a value to the value1 field by passing an integer value to the constructor when the constructor is instantiated in Main.

6. Add a method named public void display_product_calc() and use a Console.WriteLine to display the result of multiplying value1* Value2 to the console.

7. In Main declare a variable named myValue1 and assign the value 5 to it.

8. In Main instantiate a compute_product object named myproduct and pass myValue1 in the constructor parameter list.

9. In Main use the Value2 class property to set the value of class variable value2 to integer 10.

10. Call the compute_product class display_product_calc method from Main; the displayed result will be 50.




my code runs but gives the wrong output


using System;

public class compute_product
private int value1;
private int value2;

public int Value2 {get; set;} 

//value1 =Value1;
//value2 = Value2;

int result;

public compute_product(int myValue1)
value1 = myValue1;

} // end three-parameter constructor

public void display_product_calccompute() 
result = value1 * Value2;

Console.WriteLine( "The product is " + result);


static void Main(string[] args)
int myValue1 = 5;

compute_product myproduct = new compute_product(myValue1);

int value2 = 10;


Powered by