Create a class named numbers whose main method holds two


Q1.

A) Create a class named Numbers whose Main() method holds two integer variables. Assign values to the variables. Within the class, create two methods, Sum () and Difference (), that compute the sum of and difference between the values of the two variables, respectively. Each method should perform the computation and display the results. In turn, call each of the two methods from Main(), passing the values of the two integer variables. Save the program as Numbers.cs.

B) Add a method named Product () to the Numbers class. This method should compute the multiplication product of two integers, but not display the answer. Instead, it should return the answer to the calling Main() method, which displays the answer. Save the program as Numbers2.cs.

Q2. Create a class named Square. In the Main() method, declare an integer and prompt the user for a value. Display the value of the integer, then pass it to a method that accepts the value as a reference parameter and prints its square (the number times itself). In Main(), print the value again, proving that the original argument to the method was altered. Save the program as Square.cs.

Q3. Create a class named Square that contains fields for area and the length of a side and whose constructor requires a parameter for the length of one side of a Square. The constructor assigns its parameter to the length of the Square's side field and calls a private method that computes the area field. Also include read-only properties to get a Square's side and area. Create a class named DemoSquares that instantiates an array of 10 Square objects with sides that have values of 1 through 10. Display the values for each Square. Save the class as DemoSquares.es.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Create a class named numbers whose main method holds two
Reference No:- TGS01215815

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)