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

the answer on here is giving me error each time i tried...Problem: The Westfield

ID: 3575112 • Letter: T

Question

the answer on here is giving me error each time i tried...Problem: The Westfield Carpet company has asked you to write a Visual Basic application that calculates the price of carpeting. To calculate the price of the carpet, you multiply the area of the floor (width x Length) by the price per square foot of the carpet. For example, the area of a floor this is 12 feet long and 10 feet wide is 120 feet to cover that floor with carpet that cost $8 per square foot would cost $960. You should create a class named rectangle with the following properties as doubles: width, length, Area. The area property should be read-only. Provide a method named CalcArea that calculates the x length and stores the result in the area property. Next, create a class named carpet with the following properties: Color (string), style (string) and price (double). The application should have a form similar to the one shown in the figure below. (the carpet price is the price per square foot.) When the calculate button is clicked, the application should copy the data in the text boxes into the appropriate object properties, and then display the area and price...use bisual basic

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.Threading.Tasks;
using System.Windows.Forms;

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

        private void buttonCalc_Click(object sender, EventArgs e)
        {
           //const for the math
            const int sq_ft_per_sq_yard = 9;
            const int inches_per_foot = 12;

            //allow for calculation fo the input box.

            string strLengthFt = textBoxLengthFt.Text.Trim();
            string strLengthIn = textBoxLengthIn.Text.Trim();
            string strWidthFt = textBoxWidthFt.Text.Trim();
            string strWidthIn = textBoxWidthIn.Text.Trim();
            string strCarpetPrice = textBoxCarpetPrice.Text.Trim();

            //int var
            int roomLengthFt,
                roomLengthIn,
                roomWidthFt,
                roomWidthIn;

            //double var
            double roomLength,
                   roomWidth,
                   numOfSqFt,
                   numOfSqYd,
                   carpetPrice,
                   totalCost;

            //bool for validation
            bool isRoomLengthFt = int.TryParse(strLengthFt, out roomLengthFt);
            bool isRoomLengthIn = int.TryParse(strLengthIn, out roomLengthIn);
            bool isRoomWidthFt = int.TryParse(strWidthFt, out roomWidthFt);
            bool isRoomWidthIn = int.TryParse(strWidthIn, out roomWidthIn);
            bool isCarpetPrice = double.TryParse(strCarpetPrice, out carpetPrice);

            //numeric validation for textboxes
            if ((isRoomLengthFt) && (isRoomLengthIn) && (isRoomWidthFt) && (isRoomWidthIn) && (isCarpetPrice))
            {
                roomLength = roomLengthFt + (double)roomLengthIn / inches_per_foot;
                roomWidth = roomWidthFt + (double)roomWidthIn / inches_per_foot;
                numOfSqFt = roomLength * roomWidth;
                numOfSqYd = numOfSqFt / sq_ft_per_sq_yard;
                totalCost = numOfSqYd * carpetPrice;

                textBoxTotal.Text = totalCost.ToString("c");
            }
            else
            {
                MessageBox.Show("Please enter a number");
            }

          
        }

        private void buttonClear_Click(object sender, EventArgs e)
        {
            //clears selection for all text boxes
            textBoxLengthFt.Clear();
            textBoxLengthIn.Clear();
            textBoxWidthFt.Clear();
            textBoxWidthIn.Clear();
            textBoxTotal.Clear();
            textBoxCarpetPrice.Clear();

        }
    }
}


Form1.Designer.cs

namespace Carpet_Calculator
{
    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.buttonCalc = new System.Windows.Forms.Button();
            this.buttonClear = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.label1 = 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.label6 = new System.Windows.Forms.Label();
            this.textBoxLengthFt = new System.Windows.Forms.TextBox();
            this.textBoxLengthIn = new System.Windows.Forms.TextBox();
            this.textBoxWidthFt = new System.Windows.Forms.TextBox();
            this.textBoxWidthIn = new System.Windows.Forms.TextBox();
            this.textBoxCarpetPrice = new System.Windows.Forms.TextBox();
            this.textBoxTotal = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.label9 = new System.Windows.Forms.Label();
            this.label10 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.label12 = new System.Windows.Forms.Label();
            this.label13 = new System.Windows.Forms.Label();
            this.label14 = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.SuspendLayout();
            //
            // buttonCalc
            //
            this.buttonCalc.Location = new System.Drawing.Point(21, 450);
            this.buttonCalc.Name = "buttonCalc";
            this.buttonCalc.Size = new System.Drawing.Size(103, 54);
            this.buttonCalc.TabIndex = 0;
            this.buttonCalc.Text = "Calculate";
            this.buttonCalc.UseVisualStyleBackColor = true;
            this.buttonCalc.Click += new System.EventHandler(this.buttonCalc_Click);
            //
            // buttonClear
            //
            this.buttonClear.Location = new System.Drawing.Point(200, 450);
            this.buttonClear.Name = "buttonClear";
            this.buttonClear.Size = new System.Drawing.Size(103, 54);
            this.buttonClear.TabIndex = 1;
            this.buttonClear.Text = "Clear";
            this.buttonClear.UseVisualStyleBackColor = true;
            this.buttonClear.Click += new System.EventHandler(this.buttonClear_Click);
            //
            // groupBox1
            //
            this.groupBox1.Controls.Add(this.label15);
            this.groupBox1.Controls.Add(this.textBoxTotal);
            this.groupBox1.Location = new System.Drawing.Point(60, 330);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(200, 100);
            this.groupBox1.TabIndex = 2;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Total";
            //
            // groupBox2
            //
            this.groupBox2.Controls.Add(this.label13);
            this.groupBox2.Controls.Add(this.label12);
            this.groupBox2.Controls.Add(this.label11);
            this.groupBox2.Controls.Add(this.label6);
            this.groupBox2.Controls.Add(this.label5);
            this.groupBox2.Controls.Add(this.label4);
            this.groupBox2.Location = new System.Drawing.Point(12, 136);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(300, 106);
            this.groupBox2.TabIndex = 3;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Carpet Type and Pricing";
            //
            // label1
            //
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(176, 9);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(136, 13);
            this.label1.TabIndex = 4;
            this.label1.Text = "Jose Saldana JOSJB29311";
            //
            // label2
            //
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(57, 37);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(40, 13);
            this.label2.TabIndex = 5;
            this.label2.Text = "Length";
            //
            // label3
            //
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(236, 37);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(35, 13);
            this.label3.TabIndex = 6;
            this.label3.Text = "Width";
            //
            // label4
            //
            this.label4.AutoSize = true;
            this.label4.ForeColor = System.Drawing.Color.Blue;
            this.label4.Location = new System.Drawing.Point(119, 29);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(71, 13);
            this.label4.TabIndex = 0;
            this.label4.Text = "Cut and Loop";
            //
            // label5
            //
            this.label5.AutoSize = true;
            this.label5.ForeColor = System.Drawing.Color.Red;
            this.label5.Location = new System.Drawing.Point(22, 29);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(42, 13);
            this.label5.TabIndex = 1;
            this.label5.Text = "Saxony";
            //
            // label6
            //
            this.label6.AutoSize = true;
            this.label6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
            this.label6.Location = new System.Drawing.Point(233, 29);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(37, 13);
            this.label6.TabIndex = 2;
            this.label6.Text = "Velvet";
            //
            // textBoxLengthFt
            //
            this.textBoxLengthFt.Location = new System.Drawing.Point(21, 93);
            this.textBoxLengthFt.Multiline = true;
            this.textBoxLengthFt.Name = "textBoxLengthFt";
            this.textBoxLengthFt.Size = new System.Drawing.Size(42, 20);
            this.textBoxLengthFt.TabIndex = 7;
            //
            // textBoxLengthIn
            //
            this.textBoxLengthIn.Location = new System.Drawing.Point(82, 93);
            this.textBoxLengthIn.Multiline = true;
            this.textBoxLengthIn.Name = "textBoxLengthIn";
            this.textBoxLengthIn.Size = new System.Drawing.Size(42, 20);
            this.textBoxLengthIn.TabIndex = 8;
            //
            // textBoxWidthFt
            //
            this.textBoxWidthFt.Location = new System.Drawing.Point(200, 93);
            this.textBoxWidthFt.Multiline = true;
            this.textBoxWidthFt.Name = "textBoxWidthFt";
            this.textBoxWidthFt.Size = new System.Drawing.Size(42, 20);
            this.textBoxWidthFt.TabIndex = 9;
            //
            // textBoxWidthIn
            //
            this.textBoxWidthIn.Location = new System.Drawing.Point(261, 93);
            this.textBoxWidthIn.Multiline = true;
            this.textBoxWidthIn.Name = "textBoxWidthIn";
            this.textBoxWidthIn.Size = new System.Drawing.Size(42, 20);
            this.textBoxWidthIn.TabIndex = 10;
            //
            // textBoxCarpetPrice
            //
            this.textBoxCarpetPrice.Location = new System.Drawing.Point(131, 292);
            this.textBoxCarpetPrice.Multiline = true;
            this.textBoxCarpetPrice.Name = "textBoxCarpetPrice";
            this.textBoxCarpetPrice.Size = new System.Drawing.Size(56, 20);
            this.textBoxCarpetPrice.TabIndex = 11;
            //
            // textBoxTotal
            //
            this.textBoxTotal.Location = new System.Drawing.Point(74, 60);
            this.textBoxTotal.Multiline = true;
            this.textBoxTotal.Name = "textBoxTotal";
            this.textBoxTotal.ReadOnly = true;
            this.textBoxTotal.Size = new System.Drawing.Size(56, 20);
            this.textBoxTotal.TabIndex = 12;
            //
            // label7
            //
            this.label7.AutoSize = true;
            this.label7.Location = new System.Drawing.Point(18, 67);
            this.label7.Name = "label7";
            this.label7.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
            this.label7.Size = new System.Drawing.Size(33, 13);
            this.label7.TabIndex = 12;
            this.label7.Text = "Feet";
            //
            // label8
            //
            this.label8.AutoSize = true;
            this.label8.Location = new System.Drawing.Point(85, 67);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(39, 13);
            this.label8.TabIndex = 13;
            this.label8.Text = "Inches";
            //
            // label9
            //
            this.label9.AutoSize = true;
            this.label9.Location = new System.Drawing.Point(203, 67);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(28, 13);
            this.label9.TabIndex = 14;
            this.label9.Text = "Feet";
            //
            // label10
            //
            this.label10.AutoSize = true;
            this.label10.Location = new System.Drawing.Point(264, 67);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(39, 13);
            this.label10.TabIndex = 15;
            this.label10.Text = "Inches";
            //
            // label11
            //
            this.label11.AutoSize = true;
            this.label11.Location = new System.Drawing.Point(135, 62);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(40, 13);
            this.label11.TabIndex = 3;
            this.label11.Text = "$22.00";
            //
            // label12
            //
            this.label12.AutoSize = true;
            this.label12.Location = new System.Drawing.Point(22, 62);
            this.label12.Name = "label12";
            this.label12.Size = new System.Drawing.Size(40, 13);
            this.label12.TabIndex = 4;
            this.label12.Text = "$31.95";
            //
            // label13
            //
            this.label13.AutoSize = true;
            this.label13.Location = new System.Drawing.Point(230, 62);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(40, 13);
            this.label13.TabIndex = 5;
            this.label13.Text = "$14.58";
            //
            // label14
            //
            this.label14.AutoSize = true;
            this.label14.Location = new System.Drawing.Point(118, 259);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(93, 13);
            this.label14.TabIndex = 16;
            this.label14.Text = "Enter Carpet Price";
            //
            // label15
            //
            this.label15.AutoSize = true;
            this.label15.Location = new System.Drawing.Point(50, 30);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(101, 13);
            this.label15.TabIndex = 13;
            this.label15.Text = "Your total comes to:";
            //
            // Form1
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(324, 531);
            this.Controls.Add(this.label14);
            this.Controls.Add(this.label10);
            this.Controls.Add(this.label9);
            this.Controls.Add(this.label8);
            this.Controls.Add(this.label7);
            this.Controls.Add(this.textBoxCarpetPrice);
            this.Controls.Add(this.textBoxWidthIn);
            this.Controls.Add(this.textBoxWidthFt);
            this.Controls.Add(this.textBoxLengthIn);
            this.Controls.Add(this.textBoxLengthFt);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Controls.Add(this.buttonClear);
            this.Controls.Add(this.buttonCalc);
            this.Name = "Form1";
            this.Text = "Carpet Calculator";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Button buttonCalc;
        private System.Windows.Forms.Button buttonClear;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.TextBox textBoxTotal;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox textBoxLengthFt;
        private System.Windows.Forms.TextBox textBoxLengthIn;
        private System.Windows.Forms.TextBox textBoxWidthFt;
        private System.Windows.Forms.TextBox textBoxWidthIn;
        private System.Windows.Forms.TextBox textBoxCarpetPrice;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.Label label15;
        private System.Windows.Forms.Label label13;
        private System.Windows.Forms.Label label12;
        private System.Windows.Forms.Label label11;
        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.Label label14;
    }
}

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Carpet_Calculator
{
    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());
        }
    }
}