diff --git a/CalculateInvestment/CalculateInvestment.csproj b/CalculateInvestment/CalculateInvestment.csproj
index 805f01e..94e4a32 100644
--- a/CalculateInvestment/CalculateInvestment.csproj
+++ b/CalculateInvestment/CalculateInvestment.csproj
@@ -11,7 +11,7 @@
v4.5
512
true
- 1.2.32.51
+ 1.2.39.58
AnyCPU
@@ -52,6 +52,12 @@
frmInvoiceTotal.cs
+
+ Form
+
+
+ FutureValueFrm.cs
+
diff --git a/CalculateInvestment/FutureValueFrm.Designer.cs b/CalculateInvestment/FutureValueFrm.Designer.cs
new file mode 100644
index 0000000..b4f11bf
--- /dev/null
+++ b/CalculateInvestment/FutureValueFrm.Designer.cs
@@ -0,0 +1,40 @@
+
+namespace CalculateInvestment
+{
+ partial class FutureValueFrm
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Text = "FutureValueFrm";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/CalculateInvestment/FutureValueFrm.cs b/CalculateInvestment/FutureValueFrm.cs
new file mode 100644
index 0000000..151e9f4
--- /dev/null
+++ b/CalculateInvestment/FutureValueFrm.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace CalculateInvestment
+{
+ public partial class FutureValueFrm : Form
+ {
+ public FutureValueFrm()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/CalculateInvestment/Properties/AssemblyInfo.cs b/CalculateInvestment/Properties/AssemblyInfo.cs
index ace0695..edb968d 100644
--- a/CalculateInvestment/Properties/AssemblyInfo.cs
+++ b/CalculateInvestment/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.2.32.51")]
-[assembly: AssemblyFileVersion("1.2.32.51")]
+[assembly: AssemblyVersion("1.2.39.58")]
+[assembly: AssemblyFileVersion("1.2.39.58")]
diff --git a/CalculateInvestment/frmInvoiceTotal.Designer.cs b/CalculateInvestment/frmInvoiceTotal.Designer.cs
index f6ddbee..14757d7 100644
--- a/CalculateInvestment/frmInvoiceTotal.Designer.cs
+++ b/CalculateInvestment/frmInvoiceTotal.Designer.cs
@@ -48,6 +48,13 @@ private void InitializeComponent()
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btnClearTotal = new System.Windows.Forms.Button();
+ this.txtLowestInvoice = new System.Windows.Forms.TextBox();
+ this.txtLargestInvoice = new System.Windows.Forms.TextBox();
+ this.label4 = new System.Windows.Forms.Label();
+ this.label5 = new System.Windows.Forms.Label();
+ this.btnFutureValue = new System.Windows.Forms.Button();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// lbSubtotal
@@ -165,7 +172,7 @@ private void InitializeComponent()
//
// txtInvoiceAverage
//
- this.txtInvoiceAverage.Location = new System.Drawing.Point(386, 119);
+ this.txtInvoiceAverage.Location = new System.Drawing.Point(390, 83);
this.txtInvoiceAverage.Name = "txtInvoiceAverage";
this.txtInvoiceAverage.ReadOnly = true;
this.txtInvoiceAverage.Size = new System.Drawing.Size(146, 20);
@@ -175,7 +182,7 @@ private void InitializeComponent()
//
// txtTotalInvoices
//
- this.txtTotalInvoices.Location = new System.Drawing.Point(386, 93);
+ this.txtTotalInvoices.Location = new System.Drawing.Point(390, 57);
this.txtTotalInvoices.Name = "txtTotalInvoices";
this.txtTotalInvoices.ReadOnly = true;
this.txtTotalInvoices.Size = new System.Drawing.Size(146, 20);
@@ -185,7 +192,7 @@ private void InitializeComponent()
//
// txtNumOfInvoices
//
- this.txtNumOfInvoices.Location = new System.Drawing.Point(386, 67);
+ this.txtNumOfInvoices.Location = new System.Drawing.Point(390, 31);
this.txtNumOfInvoices.Name = "txtNumOfInvoices";
this.txtNumOfInvoices.ReadOnly = true;
this.txtNumOfInvoices.Size = new System.Drawing.Size(146, 20);
@@ -196,7 +203,7 @@ private void InitializeComponent()
// label1
//
this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(281, 96);
+ this.label1.Location = new System.Drawing.Point(285, 60);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 13);
this.label1.TabIndex = 13;
@@ -205,7 +212,7 @@ private void InitializeComponent()
// label2
//
this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(281, 122);
+ this.label2.Location = new System.Drawing.Point(285, 86);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 13);
this.label2.TabIndex = 12;
@@ -214,7 +221,7 @@ private void InitializeComponent()
// label3
//
this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(281, 70);
+ this.label3.Location = new System.Drawing.Point(285, 34);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(102, 13);
this.label3.TabIndex = 10;
@@ -223,7 +230,7 @@ private void InitializeComponent()
// btnClearTotal
//
this.btnClearTotal.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnClearTotal.Location = new System.Drawing.Point(263, 174);
+ this.btnClearTotal.Location = new System.Drawing.Point(264, 174);
this.btnClearTotal.Name = "btnClearTotal";
this.btnClearTotal.Size = new System.Drawing.Size(75, 23);
this.btnClearTotal.TabIndex = 3;
@@ -231,6 +238,65 @@ private void InitializeComponent()
this.btnClearTotal.UseVisualStyleBackColor = true;
this.btnClearTotal.Click += new System.EventHandler(this.btnClearTotal_Click);
//
+ // txtLowestInvoice
+ //
+ this.txtLowestInvoice.Location = new System.Drawing.Point(390, 141);
+ this.txtLowestInvoice.Name = "txtLowestInvoice";
+ this.txtLowestInvoice.ReadOnly = true;
+ this.txtLowestInvoice.Size = new System.Drawing.Size(146, 20);
+ this.txtLowestInvoice.TabIndex = 19;
+ this.txtLowestInvoice.TabStop = false;
+ this.txtLowestInvoice.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ //
+ // txtLargestInvoice
+ //
+ this.txtLargestInvoice.Location = new System.Drawing.Point(390, 115);
+ this.txtLargestInvoice.Name = "txtLargestInvoice";
+ this.txtLargestInvoice.ReadOnly = true;
+ this.txtLargestInvoice.Size = new System.Drawing.Size(146, 20);
+ this.txtLargestInvoice.TabIndex = 18;
+ this.txtLargestInvoice.TabStop = false;
+ this.txtLargestInvoice.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(285, 118);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(83, 13);
+ this.label4.TabIndex = 17;
+ this.label4.Text = "Largest Invoice:";
+ //
+ // label5
+ //
+ this.label5.AutoSize = true;
+ this.label5.Location = new System.Drawing.Point(285, 144);
+ this.label5.Name = "label5";
+ this.label5.Size = new System.Drawing.Size(82, 13);
+ this.label5.TabIndex = 16;
+ this.label5.Text = "Lowest Invoice:";
+ //
+ // btnFutureValue
+ //
+ this.btnFutureValue.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+ this.btnFutureValue.Location = new System.Drawing.Point(6, 19);
+ this.btnFutureValue.Name = "btnFutureValue";
+ this.btnFutureValue.Size = new System.Drawing.Size(165, 23);
+ this.btnFutureValue.TabIndex = 20;
+ this.btnFutureValue.Text = "Calculate Future Value";
+ this.btnFutureValue.UseVisualStyleBackColor = true;
+ this.btnFutureValue.Click += new System.EventHandler(this.btnFutureValue_Click);
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.btnFutureValue);
+ this.groupBox1.Location = new System.Drawing.Point(556, 31);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(177, 138);
+ this.groupBox1.TabIndex = 21;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Actions";
+ //
// frmInvoiceTotal
//
this.AcceptButton = this.btnCal;
@@ -238,7 +304,12 @@ private void InitializeComponent()
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonFace;
this.CancelButton = this.btnExit;
- this.ClientSize = new System.Drawing.Size(595, 216);
+ this.ClientSize = new System.Drawing.Size(800, 216);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.txtLowestInvoice);
+ this.Controls.Add(this.txtLargestInvoice);
+ this.Controls.Add(this.label4);
+ this.Controls.Add(this.label5);
this.Controls.Add(this.btnClearTotal);
this.Controls.Add(this.txtInvoiceAverage);
this.Controls.Add(this.txtTotalInvoices);
@@ -261,6 +332,7 @@ private void InitializeComponent()
this.Name = "frmInvoiceTotal";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Invoice Total";
+ this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -287,6 +359,12 @@ private void InitializeComponent()
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnClearTotal;
+ private System.Windows.Forms.TextBox txtLowestInvoice;
+ private System.Windows.Forms.TextBox txtLargestInvoice;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.Label label5;
+ private System.Windows.Forms.Button btnFutureValue;
+ private System.Windows.Forms.GroupBox groupBox1;
}
}
diff --git a/CalculateInvestment/frmInvoiceTotal.cs b/CalculateInvestment/frmInvoiceTotal.cs
index f84b30e..9c98a1c 100644
--- a/CalculateInvestment/frmInvoiceTotal.cs
+++ b/CalculateInvestment/frmInvoiceTotal.cs
@@ -12,6 +12,12 @@ namespace CalculateInvestment
{
public partial class frmInvoiceTotal :Form
{
+ int numberOfInvoices = 0;
+ decimal totalInvoices = 0m;
+
+ decimal lowestInvoice = 0m, highestInvoice = 0m;
+ bool isFirstRan = true;
+
public frmInvoiceTotal()
{
InitializeComponent();
@@ -19,48 +25,67 @@ public frmInvoiceTotal()
private void btnExit_Click(object sender, EventArgs e)
{
- this. Close();
+ this.Close();
}
- int numberOfInvoices = 0;
- decimal totalInvoices = 0m;
-
private void btnCal_Click(object sender, EventArgs e)
{
- decimal subTotal = decimal.Parse(txtEnterSubTotal.Text);
+ try
+ {
- decimal discountPercent = 0m;
+ decimal subTotal = decimal.Parse(txtEnterSubTotal.Text);
- if(subTotal >= 500)
- {
- discountPercent = 0.2m;
- }
- else if(subTotal >= 250 && subTotal < 500)
- {
- discountPercent = 0.15m;
- }
- else if (subTotal >= 100 && subTotal < 250)
- {
- discountPercent = 0.1m;
- }
+ decimal discountPercent = 0m;
- decimal discountAmt = subTotal * discountPercent;
- decimal invoiceTotal = subTotal - discountAmt;
+ if (subTotal >= 500)
+ {
+ discountPercent = 0.2m;
+ }
+ else if (subTotal >= 250 && subTotal < 500)
+ {
+ discountPercent = 0.15m;
+ }
+ else if (subTotal >= 100 && subTotal < 250)
+ {
+ discountPercent = 0.1m;
+ }
- txtDiscPerc.Text = discountPercent.ToString("p1");
- txtDiscAmt.Text = discountAmt.ToString("c2");
- txtTotal.Text = invoiceTotal.ToString("c2");
- txtSubtotal.Text = subTotal.ToString("c2");
+ decimal discountAmt = subTotal * discountPercent;
+ decimal invoiceTotal = subTotal - discountAmt;
- txtEnterSubTotal.Focus();
+ txtDiscPerc.Text = discountPercent.ToString("p1");
+ txtDiscAmt.Text = discountAmt.ToString("c2");
+ txtTotal.Text = invoiceTotal.ToString("c2");
+ txtSubtotal.Text = subTotal.ToString("c2");
+
+ txtEnterSubTotal.Focus();
+
+ numberOfInvoices++;
+ totalInvoices = totalInvoices + invoiceTotal;
+
+
+ txtNumOfInvoices.Text = numberOfInvoices.ToString();
+ txtTotalInvoices.Text = totalInvoices.ToString("c2");
+ txtInvoiceAverage.Text = (totalInvoices / numberOfInvoices).ToString("c2");
+
+ lowestInvoice = Math.Min(invoiceTotal, lowestInvoice);
+ highestInvoice = Math.Max(invoiceTotal, highestInvoice);
+
+ if (isFirstRan == true)
+ {
+ lowestInvoice = highestInvoice;
+ isFirstRan = false;
+ }
- numberOfInvoices++;
- totalInvoices = totalInvoices + invoiceTotal;
+ txtLargestInvoice.Text = highestInvoice.ToString("c2");
+ txtLowestInvoice.Text = lowestInvoice.ToString("c2");
+ }
+ catch (Exception ex)
+ {
+ MessageBox.Show(ex.Message, "Error Message!");
+ }
- txtNumOfInvoices.Text = numberOfInvoices.ToString();
- txtTotalInvoices.Text = totalInvoices.ToString("c2");
- txtInvoiceAverage.Text = (totalInvoices / numberOfInvoices).ToString("c2");
}
@@ -68,7 +93,12 @@ private void btnClearTotal_Click(object sender, EventArgs e)
{
numberOfInvoices = 0;
totalInvoices = 0m;
+ lowestInvoice = 0m;
+ highestInvoice = 0m;
+ isFirstRan = true;
+ txtLowestInvoice.Text = "";
+ txtLargestInvoice.Text = "";
txtEnterSubTotal.Text = "";
txtSubtotal.Text = "";
txtDiscPerc.Text = "";
@@ -80,5 +110,12 @@ private void btnClearTotal_Click(object sender, EventArgs e)
txtEnterSubTotal.Focus();
}
+
+ private void btnFutureValue_Click(object sender, EventArgs e)
+ {
+ FutureValueFrm futureValueFrm = new FutureValueFrm();
+ futureValueFrm.ShowDialog();
+ }
+
}
}