C-Sharp-Moment

This commit is contained in:
2022-10-18 14:28:33 -05:00
parent 97a084391c
commit 7e8bef6ba5
249 changed files with 2504 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
namespace lab5_7_CalebFontenot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void calculateButton_Click(object sender, EventArgs e)
{
try
{
// Variables
decimal sales;
decimal total = 0m;
// Declare a StreamReader variable.
StreamReader inputFile;
// Open the file and get a StreamReader object.
inputFile = File.OpenText("Sales.txt");
// Read the file's contents.
while (!inputFile.EndOfStream)
{
// Get a sales amount.
sales = decimal.Parse(inputFile.ReadLine());
// Add the sales amount to total.
total += sales;
}
// Close the file.
inputFile.Close();
// Display the total.
totalLabel.Text = total.ToString("C");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private void exitButton_Click(object sender, EventArgs e)
{
this.Close();
}
}
}