Question
1. Create a class called changeValue that declares 2 integer class variables: value1 and value2. These should be declared as public and you should not
1. Create a class called changeValue that declares 2 integer class variables: value1 and value2. These should be declared as public and you should not use automatic properties to declare them.
2. Your class should have a constructor that initializes the two class variables.
3. In the class provide a method printit() that displays the result of multiplying value1 and value2.
4. In the default wrapper class named assignment3 and containing Main write the code in Main that declares two integer variables: val1 and val2.
5. Use Console Write and Readline and the convert method to take the two integer entries from the keyboard and pass them to the changeValue constructor.
6. Instantiate a changeValue object and pass the two integer values to the constructor.
7. In the changeValue constructor evaluate the two input values that were passed using if statements:
if val1 is greater than 5 then set class variable value1 equal to the first value passed to the constructor.
if val1 is less than or equal to 5 then set class variable value1 equal to the first passed value plus the second passed value.
if val2 is less than 10 then set class variable value2 equal to the second passed value times the second passed value and then add 5.
if val2 is greater to or equal to 10 then set class variable value2 equal to the second passed value.
8. From Main call the printit method which will print the resulting computed values in the class object.
The output might look like this:
Enter an integer value: 8 Enter a second integer value: 3 The calculated value is: 112 Press any key to continue . . .
?The following is a shell for the assignment:
using System;
using System.Collections.Generic;
using System.Linq;
namespace assignment3
{
class changeValue
{
//Create a class called changeValue that declares 2 integer class variables: value1 and
// value2. These should be declared as public and you should not use automatic properties
// to declare them.
public changeValue(int val1, int val2)
{
//here is the constructor where you code the if statements
}
public void printit()
{
//here is the printit method used to print the results
}
}
class assignment3
{
public static void Main(string[] args)
{
//declare the local val1 and val2 integer variables
//prompt the user for input of two integers
//dont forget to convert from the string input to integer
//instantiate a changeValue object here
//call the object method printit here
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started