C# Computer Programming Can get code with picture how to do this assignment belo
ID: 3684633 • Letter: C
Question
C# Computer Programming Can get code with picture how to do this assignment below:
DeskGUI Basic Steps in Creating your Program 1. Create your user interface (GUI). Use different font styles but don’t overdo it, Use colors, and Use graphics (You can find all kinds of graphics for the images pizzas). Add the controls you will use for your program. You could use picture boxes, buttons, labels, combo box, radio buttons, option box and any other controls that might help in the presentation of GUI. The book has an example of what the GUI could look like, but be creative and make your own GUI. 2. Set the names of all controls. (for example, if you have a list box or label it could be txtNumber). Follow the naming convention (camel casing) for naming controls. 3. Now you are ready to write the code that will be executed by events at run time. You will probably have a button or other picture box control that you will click on at runtime. Double Click it and you will be taken to the code window where you can write code inside of the control code event handler. 4. Run and debug your program, making sure all parts work correctly. Consider data validation for the input information. As you advance to more complicated programs you will be given various ideas on validating input. 5. Remember to document your code with comments included in your code statements in the code window. Your program assignment Write a program name DeskGUI that computes the price of a desk and whose button Click Event calls the following methods: A method to accept the number of drawers in the desk as input from the key board. This method returns the number of drawers to the SelectDesk_Click event. A method to accept an input and return the type of wood, m for mahogany, o for oak, or p for pine. A method that accepts the number of drawers and wood type and calculates the cost of the desk based on the following o Pine desks are $100 o Oak desks are $140 o All other woods are $180 o A $30 surcharge is added for each drawer. o This method returns the cost to the SelectDesk_Click event. A method to display all the details and final price. All methods are void methods and receive ref or out parameters as appropriate.
Explanation / Answer
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DeskGUI
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, EventArgs e)
{
DeskCost();
}
public int NumOfDrawers()
{
string drawers;
int drawerInt;
drawers = (this.textBox1.Text);
drawerInt = Convert.ToInt32(drawers);
return drawerInt;
}
public string PickWoodType()
{
string woodType;
woodType = (this.textBox2.Text);
switch (woodType)
{
case "p":
woodType = "Pine";
break;
case "o":
woodType = "Oak";
break;
case "m":
woodType = "Mahogany";
break;
default:
woodType = ("Invalid");
break;
}
return woodType;
}
public void DeskCost()
{
string wood = PickWoodType();
double woodCost;
switch (wood)
{
case "Pine":
woodCost = 100.00;
break;
case "Oak":
woodCost = 140.00;
break;
case "Mahogany":
woodCost = 180.00;
break;
default:
woodCost = 0.00;
break;
}
this.label2.Text = "Wood Chosen: " + wood;
this.label6.Text = "Wood Cost: " + woodCost;
double deskPrice;
double totalDrawerCost;
const double drawerBase = 30.00;
int drawerTotal;
drawerTotal = (NumOfDrawers());
totalDrawerCost = (drawerTotal * drawerBase);
this.label4.Text = "Drawer Cost : " + totalDrawerCost.ToString("C");
deskPrice = (totalDrawerCost + woodCost);
this.label5.Text = "Total Cost: " + deskPrice.ToString("C");
}
}
}
Program.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace DeskGUI
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.Designer.cs
namespace DeskGUI
{
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()
{
this.btnSubmit = new System.Windows.Forms.Button();
this.lblDrawerNum = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.lblWoodType = new System.Windows.Forms.Label();
this.lblWood2 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(57, 200);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(101, 50);
this.btnSubmit.TabIndex = 0;
this.btnSubmit.Text = "Submit Order";
this.btnSubmit.UseVisualStyleBackColor = true;
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// lblDrawerNum
//
this.lblDrawerNum.AutoSize = true;
this.lblDrawerNum.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDrawerNum.Location = new System.Drawing.Point(44, 26);
this.lblDrawerNum.Name = "lblDrawerNum";
this.lblDrawerNum.Size = new System.Drawing.Size(216, 20);
this.lblDrawerNum.TabIndex = 1;
this.lblDrawerNum.Text = "Enter the Number of Drawers";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(47, 53);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(126, 20);
this.textBox1.TabIndex = 2;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(47, 140);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(126, 20);
this.textBox2.TabIndex = 3;
//
// lblWoodType
//
this.lblWoodType.AutoSize = true;
this.lblWoodType.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblWoodType.Location = new System.Drawing.Point(43, 89);
this.lblWoodType.Name = "lblWoodType";
this.lblWoodType.Size = new System.Drawing.Size(163, 20);
this.lblWoodType.TabIndex = 4;
this.lblWoodType.Text = "Enter the Wood Type:";
//
// lblWood2
//
this.lblWood2.AutoSize = true;
this.lblWood2.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblWood2.Location = new System.Drawing.Point(12, 109);
this.lblWood2.Name = "lblWood2";
this.lblWood2.Size = new System.Drawing.Size(218, 18);
this.lblWood2.TabIndex = 5;
this.lblWood2.Text = "o = oak, p = pine, m=mahogany";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(341, 77);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(0, 20);
this.label2.TabIndex = 7;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(338, 26);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(213, 31);
this.label3.TabIndex = 8;
this.label3.Text = "Order Summary:";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(341, 138);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(0, 20);
this.label4.TabIndex = 9;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(341, 190);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(0, 20);
this.label5.TabIndex = 10;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(341, 159);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(187, 13);
this.label1.TabIndex = 11;
this.label1.Text = "______________________________";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(341, 107);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(0, 20);
this.label6.TabIndex = 12;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(673, 413);
this.Controls.Add(this.label6);
this.Controls.Add(this.label1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.lblWood2);
this.Controls.Add(this.lblWoodType);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.lblDrawerNum);
this.Controls.Add(this.btnSubmit);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnSubmit;
private System.Windows.Forms.Label lblDrawerNum;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label lblWoodType;
private System.Windows.Forms.Label lblWood2;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label6;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.