Question
1 - The Summation of all numbers.
2 - The average of all number.
3 - The smallest number.
The Program should sort the numbers from the input file and place the sorted number is another file that has the prefix “sorted_” and the extension .txt that should be written in the same directory as the input file is in. Your code should only use file manipulation methods to sort the numbers. You can declare an many temporary files as you need in the process. No other method is allowed (NO Array usage, NO API). Do not declare a variable for each generated number.
4 - After sorting the number, the RichTextBox should display the median of the number sorted.
The input file that contains the random numbers should be created and the numbers should be dynamically generated in the “Form_Load” method.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
namespace Sorting{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Random rnd = new Random();
StreamWriter outputFile;
outputFile = File.CreateText("input.txt");
int sum = 0;
double total = 0.0;
int smallest = int.MaxValue;
int number;
int size = 20;
for (int i = 0; i < size; i++)
{
number = rnd.Next(1, 40);
total += number;
sum += number;
if (smallest > number)
{
smallest = number;
}...