Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Set the Addition and Level 1 radio buttons as the default when the form is loade

ID: 3735621 • Letter: S

Question

Set the Addition and Level 1 radio buttons as the default when the form is loaded. Code a void method and name it GenerateDisplayProblem. 1. 2. This method will display two random numbers in the appropriate labels. The range of the random numbers will be determined by the level of the problem. This method will display the correct operator image based upon the value of the operator radio button. If it is a subtraction problem, make sure the first number is larger than the second number since negative answers are not wanted by the teacher. If the second number is larger than swap the values. This method should be called anytime a new problem has to be displayed which should happen for any of the following scenarios: a. b. c. i. The form is initially displayed i. Any radio button is clicked. iii. If the student answers a correct answer. d. Code a returning-value method to validate the student name (required) and the student answer which should be a valid integer. Use the Error Provider control instead of the MessageBox class. Test the application. 3. a. Test the application. 4. A KeyPress event needs to be coded for the student answer textbox control. This event should only allow the digits 0 to 9 and the backspace key to be entered in the textbox control. Test the application. a. 5. Code a void method and name it CheckAnswer that will have three parameters: a. First number- integer b. Second number -integer c. Answer-integer This method should contain logic to determine if the student answer is correct. If it is correct then the happy image should be displayed in the result PictureBox, clear the answer textbox control, add 1 to the appropriate counters and call the method to generate and display a new problem, set the focus to the answer textbox control. If the answer is not correct the sad image should be displayed in the result PictureBox control, select the data contained in the answer textbox control and add 1 to the appropriate counters. d. Test the application Code a void method and name it DisplaySummaryResults. This method should calcu correct percentage and then display all the summary information using the appropriate labels. This method should be called anytime the Summary page is clicked on the tab control. 6. a. Test the application. 7. Clear Summary button: Should clear all summary output and reset all counters to zero

Explanation / Answer

Your first four divisons has been worked out:

I am not aware of error provider control class as of now.

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Syncfusion.Windows.Forms.Barcode;
using Syncfusion.Windows.Forms;
using System.Text.RegularExpressions;


namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
  
}

private void GenerateDisplayProblem(object sender, EventArgs e)
{
if(radioButton1.Checked==true)
{
pictureBox2.Image = new Bitmap(@"C:\Users\pranesh.mohanraj\Music\add.png");
}
Random rnd = new Random();
number = rnd.Next(1, 10);
number2 = rnd.Next(1, 10);
richTextBox1.Text = Convert.ToString(number);
richTextBox3.Text = Convert.ToString(number2);

}

private void pictureBox1_Click(object sender, EventArgs e)
{

}

private void pictureBox2_Click(object sender, EventArgs e)
{

}

private void richTextBox6_TextChanged(object sender, EventArgs e)
{

}

private void richTextBox3_TextChanged(object sender, EventArgs e)
{

}

private void richTextBox1_TextChanged(object sender, EventArgs e)
{

}

private void richTextBox5_TextChanged(object sender, EventArgs e)
{

}

private void button1_Click(object sender, EventArgs e)
{

int value;
if (int.TryParse(richTextBox5.Text, out value))
{
if(value == (number + number2))
{
richTextBox6.Text = "correct";
}
else
{
richTextBox6.Text = "wrong";
}
}
else
{
MessageBox.Show("Kindly enter numeric digits");
}
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
if(Regex.IsMatch(textBox1.Text, @"[a-zA-Z]"))
{

}
else
{
MessageBox.Show("kindly enter Alphabets only");
}
}
}
}

Designer class:

namespace WindowsFormsApplication2
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.richTextBox3 = new System.Windows.Forms.RichTextBox();
this.richTextBox5 = new System.Windows.Forms.RichTextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.richTextBox6 = new System.Windows.Forms.RichTextBox();
this.button1 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(22, 44);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(152, 20);
this.label1.TabIndex = 0;
this.label1.Text = "name of the student";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(167, 47);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(429, 26);
this.textBox1.TabIndex = 1;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// richTextBox1
//
this.richTextBox1.Location = new System.Drawing.Point(26, 195);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.Size = new System.Drawing.Size(78, 79);
this.richTextBox1.TabIndex = 2;
this.richTextBox1.Text = "";
this.richTextBox1.TextChanged += new System.EventHandler(this.richTextBox1_TextChanged);
//
// richTextBox3
//
this.richTextBox3.Location = new System.Drawing.Point(321, 193);
this.richTextBox3.Name = "richTextBox3";
this.richTextBox3.Size = new System.Drawing.Size(113, 80);
this.richTextBox3.TabIndex = 4;
this.richTextBox3.Text = "";
this.richTextBox3.TextChanged += new System.EventHandler(this.richTextBox3_TextChanged);
//
// richTextBox5
//
this.richTextBox5.Location = new System.Drawing.Point(732, 188);
this.richTextBox5.Name = "richTextBox5";
this.richTextBox5.Size = new System.Drawing.Size(140, 85);
this.richTextBox5.TabIndex = 6;
this.richTextBox5.Text = "";
this.richTextBox5.TextChanged += new System.EventHandler(this.richTextBox5_TextChanged);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(61, 360);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(69, 20);
this.label2.TabIndex = 7;
this.label2.Text = "operator";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(333, 358);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(69, 20);
this.label3.TabIndex = 8;
this.label3.Text = "skill level";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(716, 354);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(48, 20);
this.label4.TabIndex = 9;
this.label4.Text = "result";
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Location = new System.Drawing.Point(65, 430);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(92, 24);
this.radioButton1.TabIndex = 10;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Addition";
this.radioButton1.UseVisualStyleBackColor = true;
this.radioButton1.Click += new System.EventHandler(this.GenerateDisplayProblem);
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(337, 430);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(133, 24);
this.radioButton2.TabIndex = 11;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "level1(1 to 10)";
this.radioButton2.UseVisualStyleBackColor = true;
//
// richTextBox6
//
this.richTextBox6.Location = new System.Drawing.Point(720, 404);
this.richTextBox6.Name = "richTextBox6";
this.richTextBox6.Size = new System.Drawing.Size(153, 87);
this.richTextBox6.TabIndex = 12;
this.richTextBox6.Text = "";
this.richTextBox6.TextChanged += new System.EventHandler(this.richTextBox6_TextChanged);
//
// button1
//
this.button1.Location = new System.Drawing.Point(758, 559);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 49);
this.button1.TabIndex = 13;
this.button1.Text = "check";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(481, 195);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(159, 78);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.pictureBox1.TabIndex = 14;
this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
//
// pictureBox2
//
this.pictureBox2.Location = new System.Drawing.Point(145, 196);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(100, 78);
this.pictureBox2.TabIndex = 15;
this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(981, 655);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button1);
this.Controls.Add(this.richTextBox6);
this.Controls.Add(this.radioButton2);
this.Controls.Add(this.radioButton1);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.richTextBox5);
this.Controls.Add(this.richTextBox3);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.RichTextBox richTextBox3;
private System.Windows.Forms.RichTextBox richTextBox5;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.RichTextBox richTextBox6;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
int number=0;
int number2 = 0;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote