107 301
Assignments Done
98.9%
Successfully Done
In March 2023

# Answer to Question #248733 in C# for Anino

Question #248733


// Calculate average (only if the user inputted any numbers
if (count > 0)
average = sum / (double) count;
else
average = 0;

Create your own code to add to the original program, after Line 30. The code you add should display whether the total number of values entered by the user (count)=(4), is small

(< 5) or large (>= 5). Use an If/Else statement.

1
2021-10-08T12:19:49-0400
using System;

namespace App
{
class Program
{
static void Main(string[] args)
{

int value = 0, sum = 0, count = 0;
double average = 0.0;
// Read initial value (seed the loop)
Console.Write("Enter a positive integer (-1 to stop): ");

// if the inputted value is not the sentinel value, process it
while (value >= 0)
{

// Calculate the running total

sum += value;	// same as sum = sum + value;

// Keep track of the number of inputted values
count++;	// same as count = count + 1;

Console.Write("Enter a positive integer (-1 to stop): ");

}

// Calculate average (only if the user inputted any numbers
if (count > 0)
average = sum / (double)count;
else
average = 0;

// Print results
Console.WriteLine("sum = {0}, count = {1}", sum, count);
Console.WriteLine("average - {0:F2} ", average);
if (count >= 5)
{
Console.WriteLine("The total number of values entered by the user is large");
}
else {
Console.WriteLine("The total number of values entered by the user is small");
}

}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!