In: Computer Science
C# Language
C# CODE: (assignment.cs)
using System;
using System.Collections.Generic;
namespace Assignment3
{
class evaluateValue
{
//public variable indicators for
positive,negative,zero value
public int
zeroValue;
public int
positiveValue;
public int
negativeValue;
// constructor ,based on the
value of val ,setting the indicators
public evaluateValue(int
val)
{
// setting
positiveValue indicator
if(val >
0)
{
positiveValue = 1;
}
// setting
negativeValue indicator
if (val <
0)
{
negativeValue = 1;
}
// setting
zeroValue indicator
if (val ==
0)
{
zeroValue = 1;
}
}
// printing the results
public void
printit()
{
if(zeroValue ==
1)
{
Console.WriteLine("The number was zero.");
}
if(positiveValue
== 1)
{
Console.WriteLine("The number was
positive.");
}
if(negativeValue
== 1)
{
Console.WriteLine("The number was
negative.");
}
}
}
class assignment3
{
public static void
Main(string[] args)
{
//declare the local val1 variable
int val1;
//prompt the user for input of one integer
Console.Write( " Enter an integer value: ");
val1 = Convert.ToInt32(Console.ReadLine() );
//instantiate a evaluateValue object here
// and pass val1 to the constructor
evaluateValue ob = new evaluateValue(val1);
//call the object method printit here
ob.printit();
}
}
}
SCREENSHOT FOR OUTPUT: