finished
This commit is contained in:
parent
08bc2c16e1
commit
50ec054dd0
19
ElementaryMathematics/Form1.Designer.cs
generated
19
ElementaryMathematics/Form1.Designer.cs
generated
@ -41,6 +41,7 @@
|
|||||||
this.lblDisIncorrect = new System.Windows.Forms.Label();
|
this.lblDisIncorrect = new System.Windows.Forms.Label();
|
||||||
this.lblDisCorrect = new System.Windows.Forms.Label();
|
this.lblDisCorrect = new System.Windows.Forms.Label();
|
||||||
this.pnlCalc = new System.Windows.Forms.Panel();
|
this.pnlCalc = new System.Windows.Forms.Panel();
|
||||||
|
this.lblDisInfo = new System.Windows.Forms.Label();
|
||||||
this.lblImage = new System.Windows.Forms.Label();
|
this.lblImage = new System.Windows.Forms.Label();
|
||||||
this.btnReset = new System.Windows.Forms.Button();
|
this.btnReset = new System.Windows.Forms.Button();
|
||||||
this.btnClear = new System.Windows.Forms.Button();
|
this.btnClear = new System.Windows.Forms.Button();
|
||||||
@ -160,6 +161,7 @@
|
|||||||
//
|
//
|
||||||
// pnlCalc
|
// pnlCalc
|
||||||
//
|
//
|
||||||
|
this.pnlCalc.Controls.Add(this.lblDisInfo);
|
||||||
this.pnlCalc.Controls.Add(this.lblImage);
|
this.pnlCalc.Controls.Add(this.lblImage);
|
||||||
this.pnlCalc.Controls.Add(this.btnReset);
|
this.pnlCalc.Controls.Add(this.btnReset);
|
||||||
this.pnlCalc.Controls.Add(this.btnClear);
|
this.pnlCalc.Controls.Add(this.btnClear);
|
||||||
@ -176,6 +178,15 @@
|
|||||||
this.pnlCalc.Size = new System.Drawing.Size(698, 155);
|
this.pnlCalc.Size = new System.Drawing.Size(698, 155);
|
||||||
this.pnlCalc.TabIndex = 3;
|
this.pnlCalc.TabIndex = 3;
|
||||||
//
|
//
|
||||||
|
// lblDisInfo
|
||||||
|
//
|
||||||
|
this.lblDisInfo.Location = new System.Drawing.Point(367, 15);
|
||||||
|
this.lblDisInfo.Name = "lblDisInfo";
|
||||||
|
this.lblDisInfo.Size = new System.Drawing.Size(106, 29);
|
||||||
|
this.lblDisInfo.TabIndex = 11;
|
||||||
|
this.lblDisInfo.Text = "Rount to the Nearest Hundredth (x.xx)";
|
||||||
|
this.lblDisInfo.Click += new System.EventHandler(this.label1_Click);
|
||||||
|
//
|
||||||
// lblImage
|
// lblImage
|
||||||
//
|
//
|
||||||
this.lblImage.Location = new System.Drawing.Point(508, 37);
|
this.lblImage.Location = new System.Drawing.Point(508, 37);
|
||||||
@ -225,9 +236,9 @@
|
|||||||
//
|
//
|
||||||
// lblMessage
|
// lblMessage
|
||||||
//
|
//
|
||||||
this.lblMessage.Location = new System.Drawing.Point(425, 101);
|
this.lblMessage.Location = new System.Drawing.Point(380, 101);
|
||||||
this.lblMessage.Name = "lblMessage";
|
this.lblMessage.Name = "lblMessage";
|
||||||
this.lblMessage.Size = new System.Drawing.Size(77, 24);
|
this.lblMessage.Size = new System.Drawing.Size(206, 24);
|
||||||
this.lblMessage.TabIndex = 5;
|
this.lblMessage.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// lblOperator
|
// lblOperator
|
||||||
@ -300,7 +311,7 @@
|
|||||||
this.btnPrint.Name = "btnPrint";
|
this.btnPrint.Name = "btnPrint";
|
||||||
this.btnPrint.Size = new System.Drawing.Size(106, 34);
|
this.btnPrint.Size = new System.Drawing.Size(106, 34);
|
||||||
this.btnPrint.TabIndex = 6;
|
this.btnPrint.TabIndex = 6;
|
||||||
this.btnPrint.Text = "Print";
|
this.btnPrint.Text = "Print Summary";
|
||||||
this.btnPrint.UseVisualStyleBackColor = true;
|
this.btnPrint.UseVisualStyleBackColor = true;
|
||||||
this.btnPrint.Click += new System.EventHandler(this.button1_Click);
|
this.btnPrint.Click += new System.EventHandler(this.button1_Click);
|
||||||
//
|
//
|
||||||
@ -329,6 +340,8 @@
|
|||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label lblDisInfo;
|
||||||
|
|
||||||
private System.Windows.Forms.Button btnExit;
|
private System.Windows.Forms.Button btnExit;
|
||||||
private System.Windows.Forms.Button btnPrint;
|
private System.Windows.Forms.Button btnPrint;
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics.Eventing.Reader;
|
using System.Diagnostics.Eventing.Reader;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -23,6 +24,7 @@ namespace ElementaryMathematics
|
|||||||
private Int32 numRunningIncorrect = 0;
|
private Int32 numRunningIncorrect = 0;
|
||||||
|
|
||||||
private bool hasTried = false;
|
private bool hasTried = false;
|
||||||
|
private bool isError = false;
|
||||||
|
|
||||||
|
|
||||||
public Form1()
|
public Form1()
|
||||||
@ -61,7 +63,13 @@ namespace ElementaryMathematics
|
|||||||
|
|
||||||
private void button1_Click(object sender, EventArgs e)
|
private void button1_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// throw new System.NotImplementedException();
|
decimal total = (numRunningCorrect - numRunningIncorrect) * 100;
|
||||||
|
|
||||||
|
MessageBox.Show("Your Score:" +
|
||||||
|
"\nCorrect: " + numRunningCorrect +
|
||||||
|
"\nIncorrect: " + numRunningIncorrect +
|
||||||
|
"\nTotal Score : " + (total.ToString()+"!"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeOperator(string op)
|
private void ChangeOperator(string op)
|
||||||
@ -100,21 +108,33 @@ namespace ElementaryMathematics
|
|||||||
private void rdoAddition_CheckedChanged(object sender, EventArgs e)
|
private void rdoAddition_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ChangeOperator("+");
|
ChangeOperator("+");
|
||||||
|
UpdateButtons();
|
||||||
|
isError = false;
|
||||||
|
hasTried = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rdoSubtraction_CheckedChanged(object sender, EventArgs e)
|
private void rdoSubtraction_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ChangeOperator("-");
|
ChangeOperator("-");
|
||||||
|
UpdateButtons();
|
||||||
|
isError = false;
|
||||||
|
hasTried = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rdoMultiplication_CheckedChanged(object sender, EventArgs e)
|
private void rdoMultiplication_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ChangeOperator("*");
|
ChangeOperator("*");
|
||||||
|
UpdateButtons();
|
||||||
|
isError = false;
|
||||||
|
hasTried = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rdoDivision_CheckedChanged(object sender, EventArgs e)
|
private void rdoDivision_CheckedChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ChangeOperator("/");
|
ChangeOperator("/");
|
||||||
|
UpdateButtons();
|
||||||
|
isError = false;
|
||||||
|
hasTried = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnExit_Click(object sender, EventArgs e)
|
private void btnExit_Click(object sender, EventArgs e)
|
||||||
@ -137,24 +157,35 @@ namespace ElementaryMathematics
|
|||||||
{
|
{
|
||||||
answer = a + b;
|
answer = a + b;
|
||||||
hasTried = true;
|
hasTried = true;
|
||||||
|
return answer;
|
||||||
}else if (isSubtract)
|
}else if (isSubtract)
|
||||||
{
|
{
|
||||||
answer = a - b;
|
answer = a - b;
|
||||||
hasTried = true;
|
hasTried = true;
|
||||||
|
return answer;
|
||||||
}else if (isMultiply)
|
}else if (isMultiply)
|
||||||
{
|
{
|
||||||
answer = a * b;
|
answer = a * b;
|
||||||
hasTried = true;
|
hasTried = true;
|
||||||
|
return answer;
|
||||||
}else if (isDivide)
|
}else if (isDivide)
|
||||||
{
|
{
|
||||||
hasTried = true;
|
hasTried = true;
|
||||||
if (b != 0)
|
if (b != 0)
|
||||||
{
|
{
|
||||||
answer = a / b;
|
string newan;
|
||||||
|
answer = a / b;
|
||||||
|
newan = answer.ToString("F");
|
||||||
|
answer = decimal.Parse(newan);
|
||||||
|
return answer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception();
|
ep1.SetError(btnChkAnswer, "Cannot Divide by 0!");
|
||||||
|
isError = true;
|
||||||
|
answer = new decimal(null);
|
||||||
|
return answer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -170,7 +201,7 @@ namespace ElementaryMathematics
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return answer;
|
return new decimal(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Win()
|
private void Win()
|
||||||
@ -231,7 +262,7 @@ namespace ElementaryMathematics
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
ep1.SetError(btnChkAnswer, "Calculation Error");
|
MessageBox.Show("NaN", "Error", MessageBoxButtons.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -265,21 +296,21 @@ namespace ElementaryMathematics
|
|||||||
|
|
||||||
private void txtA_TextChanged(object sender, EventArgs e)
|
private void txtA_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ep1.Clear();
|
isError = false;
|
||||||
hasTried = false;
|
hasTried = false;
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void txtB_TextChanged(object sender, EventArgs e)
|
private void txtB_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ep1.Clear();
|
isError = false;
|
||||||
hasTried = false;
|
hasTried = false;
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void txtC_TextChanged(object sender, EventArgs e)
|
private void txtC_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
ep1.Clear();
|
isError = false;
|
||||||
hasTried = false;
|
hasTried = false;
|
||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
lblMessage.Text = "";
|
lblMessage.Text = "";
|
||||||
@ -346,11 +377,18 @@ namespace ElementaryMathematics
|
|||||||
{
|
{
|
||||||
|
|
||||||
btnReset.Enabled = true;
|
btnReset.Enabled = true;
|
||||||
|
btnPrint.Enabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
btnReset.Enabled = false;
|
btnReset.Enabled = false;
|
||||||
|
btnPrint.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isError)
|
||||||
|
{
|
||||||
|
ep1.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -379,7 +417,7 @@ namespace ElementaryMathematics
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
lblMessage.Text = Calculate(a, b).ToString();
|
lblMessage.Text = "Correct Answer: " + Calculate(a, b).ToString("F");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
@ -407,5 +445,10 @@ namespace ElementaryMathematics
|
|||||||
UpdateButtons();
|
UpdateButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void label1_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user