Question 1 from the Lab1 Assignment sheet is in the two Screen Shots i posted, while questions 2-5 are on the Lab1 Assignment sheet already, the questions are to be done with C Sharp and Forms

1 answer below ยป
Question 1 from the Lab1 Assignment sheet is in the two Screen Shots i posted, while questions 2-5 are on the Lab1 Assignment sheet already, the questions are to be done with C Sharp and Forms

Answered 2 days AfterJan 14, 2021

Answer To: Question 1 from the Lab1 Assignment sheet is in the two Screen Shots i posted, while questions 2-5...

Swapnil answered on Jan 16 2021
148 Votes
74563/1A.csnamespace AreaPerimeterCalculator
{
    partial class AreaPerimeter
    {
    ///
    ///

    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.label1 = new System.Windows.Forms.Label();
this.btnCalculate = new System.Windows.Forms.Button();
this.btnExit = new System.Windows.Forms.Button();
this.txtLength = new System.Windows.Forms.TextBox();
this.txtWidth = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.lblArea = new System.Windows.Forms.Label();
this.lblPerimeter = new System.Windows.Forms.Label();
this.lblMessage = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(69, 57);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(40, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Length";
//
// btnCalculate
//
this.btnCalculate.Location = new System.Drawing.Point(72, 238);
this.btnCalculate.Name = "btnCalculate";
this.btnCalculate.Size = new System.Drawing.Size(75, 23);
this.btnCalculate.TabIndex = 1;
this.btnCalculate.Text = "Calculate";
this.btnCalculate.UseVisualStyleBackColor = true;
this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
//
// btnExit
//
this.btnExit.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnExit.Location = new System.Drawing.Point(182, 238);
this.btnExit.Name = "btnExit";
this.btnExit.Size = new Sys
tem.Drawing.Size(75, 23);
this.btnExit.TabIndex = 2;
this.btnExit.Text = "Exit";
this.btnExit.UseVisualStyleBackColor = true;
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// txtLength
//
this.txtLength.Location = new System.Drawing.Point(157, 50);
this.txtLength.Name = "txtLength";
this.txtLength.Size = new System.Drawing.Size(100, 20);
this.txtLength.TabIndex = 3;
//
// txtWidth
//
this.txtWidth.Location = new System.Drawing.Point(157, 90);
this.txtWidth.Name = "txtWidth";
this.txtWidth.Size = new System.Drawing.Size(100, 20);
this.txtWidth.TabIndex = 5;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(69, 97);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Width";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(69, 135);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(29, 13);
this.label3.TabIndex = 6;
this.label3.Text = "Area";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(69, 183);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(51, 13);
this.label4.TabIndex = 8;
this.label4.Text = "Perimeter";
//
// lblArea
//
this.lblArea.AutoSize = true;
this.lblArea.Location = new System.Drawing.Point(154, 135);
this.lblArea.Name = "lblArea";
this.lblArea.Size = new System.Drawing.Size(0, 13);
this.lblArea.TabIndex = 9;
//
// lblPerimeter
//
this.lblPerimeter.AutoSize = true;
this.lblPerimeter.Location = new System.Drawing.Point(154, 183);
this.lblPerimeter.Name = "lblPerimeter";
this.lblPerimeter.Size = new System.Drawing.Size(0, 13);
this.lblPerimeter.TabIndex = 10;
//
// lblMessage
//
this.lblMessage.AutoSize = true;
this.lblMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblMessage.ForeColor = System.Drawing.Color.Red;
this.lblMessage.Location = new System.Drawing.Point(55, 272);
this.lblMessage.Name = "lblMessage";
this.lblMessage.Size = new System.Drawing.Size(0, 15);
this.lblMessage.TabIndex = 11;
//
// Form1
//
this.AcceptButton = this.btnCalculate;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnExit;
this.ClientSize = new System.Drawing.Size(328, 307);
this.Controls.Add(this.lblMessage);
this.Controls.Add(this.lblPerimeter);
this.Controls.Add(this.lblArea);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtWidth);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtLength);
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnCalculate);
this.Controls.Add(this.label1);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "Form1";
this.Text = "Calculate Area and Perimeter ";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnCalculate;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.TextBox txtLength;
private System.Windows.Forms.TextBox txtWidth;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label lblArea;
private System.Windows.Forms.Label lblPerimeter;
private System.Windows.Forms.Label lblMessage;
}
}
Below is the code for AreaPerimeter.cs
using System;
using System.Windows.Forms;
namespace AreaPerimeterCalculator
{
public partial class AreaPerimeter : Form
{
public AreaPerimeter()
{
InitializeComponent();
}
private void btnCalculate_Click(object sender, EventArgs e)
{
if (txtLength.Text != "" || txtWidth.Text != "")
{
double area = 0;
double perimeter = 0;
lblMessage.Text = "";
try
{
double length = double.Parse(txtLength.Text);
double width = double.Parse(txtWidth.Text);
area = width * length;
perimeter = 2 * width + 2 * length;
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
}
lblArea.Text = area.ToString();
lblPerimeter.Text = perimeter.ToString();
}
else
{
lblMessage.Text = "Kindly Provide the value for Length or Width";
}
}
private void btnExit_Click(object sender, EventArgs e)
{
//used to exit the application
Application.Exit();
}
}
}
74563/1B.csPublic Class Form1
'local variable declare
Dim Score As Integer = 0
Dim ScoreTotal As Integer = 0
Dim ScoreCount As Integer = 0
Dim Average As Integer = 0
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Escape Then BtnExit_Click(sender, e) 'When user press Escap key Exit Button fire
End Sub
Private Sub BtnExit_Click(sender As Object, e As EventArgs) Handles BtnExit.Click
'when user click on Exit button below function call and exit to the window
Me.Close()
End Sub
Private Sub BtnClearScore_Click(sender As Object, e As EventArgs) Handles BtnClearScore.Click
'when user click Clear Score button below operation call and all texboxs value are clear
TxtScore.Text = ""
TxtScoreTotal.Text = ""
TxtScoreCount.Text = ""
TxtAverage.Text = ""
TxtScore.Select() 'when user click on clear score button clear all value and focus on score textbox
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TxtScore.Select() 'when form is load focas on score textbox
End Sub
Private Sub BtnAdd_Click(sender As Object, e As EventArgs) Handles BtnAdd.Click
Score = Convert.ToInt32(TxtScore.Text) 'value convertet in integer and store in score variable
If (Score > 0) Then 'if score value more than zero calculation below
ScoreTotal += Score ' score store in scoretotal
ScoreCount += 1 'scorecount increment 1 and stor in scorecount value
Average = ScoreTotal / ScoreCount 'average calculation
TxtScoreTotal.Text = ScoreTotal.ToString() 'store value in textbox
TxtScoreCount.Text = ScoreCount.ToString() 'store value in textbox
TxtAverage.Text = Average.ToString 'store value in textbox
Else
MessageBox.Show("Enter Valid Score") 'else message box display
End If
End Sub
End Class
74563/2.csusing System;
public class App
{
public static void Main()
{
int seed = 345;
int min = -44;
int max = 30;
Console.WriteLine("Testing 6 random Int32 from 0 to Int32.MAX");
Random r1 = new Random(seed);
for (int j = 0; j < 6; j++)
Console.Write("{0,11} ", r1.Next());
Console.WriteLine("Testing 6 random int32 from 0 to 30");
Random r2 = new Random(seed);
for (int j = 0; j < 6; j++)
Console.Write("{0,11} ", r2.Next(max));
Console.WriteLine("Testing 6 random int32 from -44 to 30");
Random r3 = new Random(seed);
for (int j = 0; j < 6; j++)
Console.Write("{0,11} ", r3.Next(min, max));
Console.WriteLine("Testing 5 random bytes: 0 to 255");
Random r4 = new Random();
Byte[] b = new Byte[10];
r4.NextBytes(b);
Console.WriteLine("The Random bytes are: ");
for (int i = 0; i < 10; i++)
{
Console.Write(i);
Console.Write(":");
Console.WriteLine(b[i]);
}
Console.WriteLine("Testing 6 random doubles from 0 to 1");
Random r5 = new Random(seed);
for (int j = 0; j < 6; j++)
Console.WriteLine("{0,11} ",r5.NextDouble());
Console.WriteLine("Testing 6 random doubles from -44 to 30");
Random r6 = new Random(seed);
for (int j = 0; j < 6; j++)
Console.WriteLine("{0,11}",(min+(max-min)*r6.NextDouble()));
}
}
74563/3.csnamespace SimpleCalculator
{
partial class Form1
{
///
/// 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.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.txtValue1 = new System.Windows.Forms.TextBox();
this.txtAnswer = new System.Windows.Forms.TextBox();
this.txtValue2 = new System.Windows.Forms.TextBox();
this.rdbtnAdd = new System.Windows.Forms.RadioButton();
this.rdbtnSub = new System.Windows.Forms.RadioButton();
this.rdbtnMul = new System.Windows.Forms.RadioButton();
this.rdbtnDiv = new System.Windows.Forms.RadioButton();
this.btnCalculate = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(43, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(49, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Value 1 :";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(43, 81);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(49, 13);
this.label2.TabIndex = 1;
this.label2.Text = "Value 2 :";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(43, 124);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 13);
this.label3.TabIndex = 2;
this.label3.Text = "Answer :";
//
// txtValue1
//
this.txtValue1.Location = new System.Drawing.Point(113, 40);
this.txtValue1.Name = "txtValue1";
this.txtValue1.Size = new System.Drawing.Size(100, 20);
this.txtValue1.TabIndex = 3;
//
// txtAnswer
//
this.txtAnswer.Location = new System.Drawing.Point(113, 121);
this.txtAnswer.Name = "txtAnswer";
this.txtAnswer.Size = new System.Drawing.Size(100, 20);
this.txtAnswer.TabIndex = 4;
//
// txtValue2
//
this.txtValue2.Location = new System.Drawing.Point(113, 78);
this.txtValue2.Name = "txtValue2";
this.txtValue2.Size = new System.Drawing.Size(100, 20);
this.txtValue2.TabIndex = 5;
//
// rdbtnAdd
//
this.rdbtnAdd.AutoSize = true;
this.rdbtnAdd.Location = new System.Drawing.Point(261, 39);
this.rdbtnAdd.Name = "rdbtnAdd";
this.rdbtnAdd.Size = new System.Drawing.Size(65, 17);
this.rdbtnAdd.TabIndex = 7;
this.rdbtnAdd.TabStop = true;
this.rdbtnAdd.Text = "Add ( + )";
this.rdbtnAdd.UseVisualStyleBackColor = true;
this.rdbtnAdd.CheckedChanged += new System.EventHandler(this.rdbtnAdd_CheckedChanged);
//
// rdbtnSub
//
this.rdbtnSub.AutoSize = true;
this.rdbtnSub.Location = new System.Drawing.Point(261, 77);
this.rdbtnSub.Name = "rdbtnSub";
this.rdbtnSub.Size = new System.Drawing.Size(83, 17);
this.rdbtnSub.TabIndex = 8;
this.rdbtnSub.TabStop = true;
this.rdbtnSub.Text = "Subtract ( - )";
this.rdbtnSub.UseVisualStyleBackColor = true;
this.rdbtnSub.CheckedChanged += new System.EventHandler(this.rdbtnSub_CheckedChanged);
//
// rdbtnMul
//
this.rdbtnMul.AutoSize = true;
this.rdbtnMul.Location = new System.Drawing.Point(261, 111);
this.rdbtnMul.Name = "rdbtnMul";
this.rdbtnMul.Size = new System.Drawing.Size(79, 17);
this.rdbtnMul.TabIndex = 9;
this.rdbtnMul.TabStop = true;
this.rdbtnMul.Text = "Multiply ( * )";
this.rdbtnMul.UseVisualStyleBackColor = true;
this.rdbtnMul.CheckedChanged += new System.EventHandler(this.rdbtnMul_CheckedChanged);
//
// rdbtnDiv
//
this.rdbtnDiv.AutoSize = true;
this.rdbtnDiv.Location = new System.Drawing.Point(261, 149);
this.rdbtnDiv.Name = "rdbtnDiv";
this.rdbtnDiv.Size = new System.Drawing.Size(75, 17);
this.rdbtnDiv.TabIndex = 10;
this.rdbtnDiv.TabStop = true;
this.rdbtnDiv.Text = "Divide ( / )";
this.rdbtnDiv.UseVisualStyleBackColor = true;
this.rdbtnDiv.CheckedChanged += new System.EventHandler(this.rdbtnDiv_CheckedChanged);
//
// btnCalculate
//
this.btnCalculate.Location = new System.Drawing.Point(151, 191);
this.btnCalculate.Name = "btnCalculate";
this.btnCalculate.Size = new System.Drawing.Size(75, 23);
this.btnCalculate.TabIndex = 11;
this.btnCalculate.Text = "Calculate";
this.btnCalculate.UseVisualStyleBackColor = true;
this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(384, 262);
this.Controls.Add(this.btnCalculate);
this.Controls.Add(this.rdbtnDiv);
this.Controls.Add(this.rdbtnMul);
this.Controls.Add(this.rdbtnSub);
this.Controls.Add(this.rdbtnAdd);
this.Controls.Add(this.txtValue2);
this.Controls.Add(this.txtAnswer);
this.Controls.Add(this.txtValue1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Simple Calculator";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtValue1;
private System.Windows.Forms.TextBox txtAnswer;
private System.Windows.Forms.TextBox txtValue2;
private System.Windows.Forms.RadioButton rdbtnAdd;
private System.Windows.Forms.RadioButton rdbtnSub;
private System.Windows.Forms.RadioButton rdbtnMul;
private System.Windows.Forms.RadioButton rdbtnDiv;
private System.Windows.Forms.Button btnCalculate;
}
}
74563/4.csFactorialCalculator.cs
//Include the classes.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
//Create the class
public partial class Form1 : Form
{
//Define the constructor.
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}

//Add the event on the exit button.
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}

//Add the event on button calculate button.
private void button1_Click(object sender, EventArgs e)
{
//define the variable.
int num = Convert.ToInt32(textBox1.Text);
long factn = 1;

//Implement the factorial logic.
for (int iter = num; iter > 0; iter--)
{
factn = factn * iter;
}

//Store the value in string form.
//Add comma as per the currency to the value.
String str = factn.ToString("C", CultureInfo.CreateSpecificCulture("ja-JP"));
//Display the result in textbox.
//Skip the currency symbol.
textBox2.Text = str.Substring(1);

}

}
}
FactorialCalculator.designer.cs
namespace WindowsFormsApplication1
{
partial class Form1
{
///
/// 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.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Location = new
System.Drawing.Point(292, 41);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(216, 26);
this.textBox1.TabIndex = 0;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(292, 114);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(216, 26);
this.textBox2.TabIndex = 2;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(120, 44);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 20);
this.label1.TabIndex = 3;
this.label1.Text = "Number";
this.label1.Click += new System.EventHandler(this.label1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(120, 114);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 20);
this.label2.TabIndex = 5;
this.label2.Text = "Factorial";
//
// button1
//
this.button1.Location = new System.Drawing.Point(105, 176);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(127, 37);
this.button1.TabIndex = 6;
this.button1.Text = "Calculate";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(292, 176);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(149,37);
this.button2.TabIndex = 8;
this.button2.Text = "Exit";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new
System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(605, 310);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox2);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here