Since the programming language is not used, C# programming has been used for solution.
//creating an interface with all abstract methods
interface CounterInterface
{
void SetCounter(); //method to set positive and negative
counter
void IncreaseCounter(); //method to increase counter for
non-negative numbers
void DecreaseCounter(); // method to increase counter for negative
numbers
void ReturnCuttentCountAsString(); // method to display the current
count
}
//Class Counter implementing the interface
CounterInterface
class Counter : CounterInterface
{
//two fields are declared as static to check positive and negative
count
public static int positiveCount;
public static int NegativeCount;
//setting counter values to 0
public void SetCounter()
{
positiveCount = 0;
NegativeCount = 0;
}
//increasing the counter for positive numbers
public void IncreaseCounter()
{
positiveCount = positiveCount + 1;
}
//increasing the counter for negative numbers
public void DecreaseCounter()
{
NegativeCount = NegativeCount + 1;
}
//returning the current counter as a string
public void ReturnCuttentCountAsString()
{
Console.WriteLine("Curent Postive Count is : " +
positiveCount);
Console.WriteLine("Curent Negative Count is : " +
NegativeCount);
}
}
class Program
{
static void Main(string[] args)
{
//declaring an array and assigning values
int[] numbers = { 1,2,6,5,6,98,0,-8,-7,8,9,-5,1,-2,0};
//creating object of Counter class
Counter obj = new Counter();
//call counter method to initialize values
obj.SetCounter();
//iterate over each element and increase counter of numbers based
on the condition
foreach (var item in numbers)
{
if (item == 0)
{
//do nothing
}
else if (item > 0)
{
obj.IncreaseCounter(); //call method to increase positive
count
}
else
{
obj.DecreaseCounter(); //call method to increase negative
count
}
}
//call the method to display the result
obj.ReturnCuttentCountAsString();
}
}
Hello, Someone help me with this data structure exercise. There is 2 part.
Hello can someone help me answer this plz? Part C confuses me Exercise 4: Calculate Inflation and Compare CPI vs GDP Deflator (14) Consider an economy in which pizzas and burgers are produced. In year 1, 20 million pounds of pizzas are produced and consumed, and the price of pizza is $2 per pound, while 40 million pounds of burgers are produced and consumed and the price of burger is $0.50 per pound. In year 2, 30 million pounds of...
hello! can someone help me with equations involving inverse trigonometric functions?
Hello, I've been stuck on this question for hours. Can someone help me solve part a, and part b of this questions with steps for referencing back on how to solve this kind of chemistry problem? Question: If 52.85 mL of 0.740 M aqueous magnesium chloride reacts with 114.41 mL of 0.860 M aqueous sodium phosphate to form aqueous sodium chloride and solid magnesium phosphate: a. What is the balanced chemical reaction? (include phases) b. How many grams of magnesium...
hello,can someone help me with Henry III reading question and answer?
Hello, I need someone to help me solving this problem, please. ================ For the code sequence below: add $1, $2, $3 sub $4, $1, $5 and $6, $1, $7 or $8, $1, $9 xor $4, $1, $5 1) Draw the pipelined dependences. 2) Show the forwarding paths needed to resolve the data hazards.
Hello, could someone help me with understanding what is covered call? And how to interpret it and differentiate it from protective option?
Hello everyone I want someone can help me for this equation subject is electronic Thanks
Can someone please help me with this data structure class exercise? Will rate b. Given the following sorted singly linked list 5 header 1 shown above to trace the a) Use the implemented sorted linked list and the sorted linked list L following statements. Draw the status of the new list after each statement. List L2(L1) L2.insert(5); L2 insert (7); L2. insert(4); cout<cL2; し2.erase(4); し2.erase(7); cout«<L2;
Hello! Can someone help me make this prototyping model into iterative model? Photo attached. Analyzing the Study Identifying the hardware Project proposal Identifying the Software Data Gathering Finalizing the documentation Testing the Prototype Creating a Diagram Checking the System Prototyping Designing Prototype Building Canvassing Designing the Purchasing the Materials Circuit
Hello, I am reviewing my chemistry problems and need someone to draw me the structure + stereochemistry of the following: 1. (2R,3S) and (2S,3R) erythro-2,3-dibromo-3-phenylpropanoic acid 2. 2R, 3R) and (2S, 3S) threo-2,3-dibromo-3phenylpropanoic acid 3. Structure and stereochemistry of a mixture of both eryhtro and threo-2,3-dibromo-3phenylpropanoic acid Please include all mechanisms that show how you obtain the different stereoisomer! (please show the stereochemical outcome of a brominum ion intermediate versus a carbocation intermediate versus a four atoms concerted transition state)