Question: Without using .Min and .Max, can you please complete problem #2? My code is dropping numbers after the decimal. Not sure where I am going
Without using .Min and .Max, can you please complete problem #2? My code is dropping numbers after the decimal. Not sure where I am going wrong. I cannot figure out how to get the code to work with .Min or .Max as well. Thank you!
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;
namespace Total_Sales_Sales_Analysis_Program { public partial class salesAnalysisFormKS : Form { public salesAnalysisFormKS() { InitializeComponent(); }
private double Average(int[] iArray) { int total = 0; double average;
for (int index = 0; index
average = (double)total / iArray.Length;
return average; }
private double Highest(int[] iArray) { int highest = iArray[0]; for (int index = 1; index highest) { highest = iArray[index]; } } return highest; }
private int Lowest(int[] iArray) { int lowest = iArray[0];
for (int index = 1; index
private void getValuesButtonKS_Click(object sender, EventArgs e) { try {
double[] salesArray = new double[7]; string inputFile = ""; int index = 0; double totalSales = 0; int lowest = 0; int highest = 0;
StreamReader inputNew = new StreamReader("Sales.txt");
while ((inputFile = inputNew.ReadLine()) != null) {
outputListBoxKS.Items.Add(inputFile); salesArray[index] = double.Parse(inputFile); totalSales = totalSales + salesArray[index]; lowest = (int)salesArray.Min(); highest = (int)salesArray.Max(); index++;
}
averageLabelOutputKS.Text = totalSales.ToString(""); lowestOutputLabelKS.Text = lowest.ToString("0.00"); highestOutputLabelKS.Text = highest.ToString("0.00");
} catch (Exception ex) { MessageBox.Show(ex.Message); }
}
private void exitButton_Click(object sender, EventArgs e) { this.Close(); }
private void averageLabelOutputKS_Click(object sender, EventArgs e) {
} } }

list that contains the valid charge account numbers. If al e s x Create an application that reads the contents of the file into an array or a List. The application should then let the user enter a charge account number. The should determine whether the number is valid by searching for it in the array or Arrays and Lists Programming Problems 1. Total Sales In the Chap07 folder of the Student Sample Programs, you will find a file named Sales.txt. Figure 7-44 shows the file's contents displayed in Notepad. Create an application that reads this file's contents into an array, displays the array's contents in a ListBox control, and calculates and displays the total of the array's values. Figure 7-44 The Sales.txt file Sales.txt - Notepad 2. Sales Analysis Modify the application that you created in Programming Exercise 1 so it also displays the following: The average of the values in the array The largest value in the array The smallest value in the array 3. Charge Account Validation In the Chap07 folder of the Student Sample Programs, you will find a file named ChargeAccounts.txt. The file contains a list of a company's valid charge account numbers. There are a total of 18 charge account numbers in the file, and each one is a 7-digit number, such as 5658845. File Edit Format View Help 1245.67 1189.55 1098.72 1456.88 2109.34 1987.55 1872.36 program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
