Answer to Question #250434 in C# for nick

Question #250434

Create a windows desktop application which can be used by a local gardening service to determine the amount due by customers.


Your program should request the user to input the approximate length and breadth of the lawn, and whether cleaning the flower beds are included. Your program should then calculate and display the amount due, which is R8 per square meter of lawn, and a fixed cost of R60 if the flower beds needs to be cleaned.



1
Expert's answer
2021-10-12T13:49:40-0400
namespace GardeningService
{
    partial class frmGardeningService
    {
        /// <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.label1 = new System.Windows.Forms.Label();
            this.btnCalculate = new System.Windows.Forms.Button();
            this.cbIncludeCleaningFlowerBeds = new System.Windows.Forms.CheckBox();
            this.txtLengthLawn = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.txtBreadthLawn = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.txtAmountDue = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // label1
            // 
            this.label1.AutoSize = true;
            this.label1.Location = new System.Drawing.Point(36, 32);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(139, 13);
            this.label1.TabIndex = 0;
            this.label1.Text = "Input the length of the lawn:";
            // 
            // btnCalculate
            // 
            this.btnCalculate.Location = new System.Drawing.Point(188, 167);
            this.btnCalculate.Name = "btnCalculate";
            this.btnCalculate.Size = new System.Drawing.Size(100, 23);
            this.btnCalculate.TabIndex = 4;
            this.btnCalculate.Text = "Calculate";
            this.btnCalculate.UseVisualStyleBackColor = true;
            this.btnCalculate.Click += new System.EventHandler(this.btnCalculate_Click);
            // 
            // cbIncludeCleaningFlowerBeds
            // 
            this.cbIncludeCleaningFlowerBeds.AutoSize = true;
            this.cbIncludeCleaningFlowerBeds.Location = new System.Drawing.Point(39, 97);
            this.cbIncludeCleaningFlowerBeds.Name = "cbIncludeCleaningFlowerBeds";
            this.cbIncludeCleaningFlowerBeds.Size = new System.Drawing.Size(208, 17);
            this.cbIncludeCleaningFlowerBeds.TabIndex = 3;
            this.cbIncludeCleaningFlowerBeds.Text = "Include cleaning the flower beds (R60)";
            this.cbIncludeCleaningFlowerBeds.UseVisualStyleBackColor = true;
            // 
            // txtLengthLawn
            // 
            this.txtLengthLawn.Location = new System.Drawing.Point(188, 29);
            this.txtLengthLawn.Name = "txtLengthLawn";
            this.txtLengthLawn.Size = new System.Drawing.Size(100, 20);
            this.txtLengthLawn.TabIndex = 1;
            // 
            // label2
            // 
            this.label2.AutoSize = true;
            this.label2.Location = new System.Drawing.Point(36, 58);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(146, 13);
            this.label2.TabIndex = 0;
            this.label2.Text = "Input the breadth of the lawn:";
            // 
            // txtBreadthLawn
            // 
            this.txtBreadthLawn.Location = new System.Drawing.Point(188, 55);
            this.txtBreadthLawn.Name = "txtBreadthLawn";
            this.txtBreadthLawn.Size = new System.Drawing.Size(100, 20);
            this.txtBreadthLawn.TabIndex = 2;
            // 
            // label3
            // 
            this.label3.AutoSize = true;
            this.label3.Location = new System.Drawing.Point(115, 133);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(67, 13);
            this.label3.TabIndex = 0;
            this.label3.Text = "Amount due:";
            // 
            // txtAmountDue
            // 
            this.txtAmountDue.Location = new System.Drawing.Point(188, 129);
            this.txtAmountDue.Name = "txtAmountDue";
            this.txtAmountDue.ReadOnly = true;
            this.txtAmountDue.Size = new System.Drawing.Size(100, 20);
            this.txtAmountDue.TabIndex = 3;
            this.txtAmountDue.TabStop = false;
            // 
            // frmGardeningService
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(313, 204);
            this.Controls.Add(this.txtAmountDue);
            this.Controls.Add(this.txtBreadthLawn);
            this.Controls.Add(this.txtLengthLawn);
            this.Controls.Add(this.label3);
            this.Controls.Add(this.cbIncludeCleaningFlowerBeds);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.btnCalculate);
            this.Controls.Add(this.label1);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
            this.Name = "frmGardeningService";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Gardening service";
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button btnCalculate;
        private System.Windows.Forms.CheckBox cbIncludeCleaningFlowerBeds;
        private System.Windows.Forms.TextBox txtLengthLawn;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox txtBreadthLawn;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox txtAmountDue;
    }
}












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 GardeningService
{
    public partial class frmGardeningService : Form
    {
        public frmGardeningService()
        {
            InitializeComponent();
        }
        /// <summary>
        /// Calculate button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCalculate_Click(object sender, EventArgs e)
        {
            double breadthLawn;
            double lengthLawn;
            double.TryParse(txtBreadthLawn.Text, out breadthLawn);
            double.TryParse(txtLengthLawn.Text, out lengthLawn);
            //R8 per square meter of lawn;
            const double PRICE_PERSQUARE = 8.0;
            double amoutDue = breadthLawn * lengthLawn * PRICE_PERSQUARE;
            if (cbIncludeCleaningFlowerBeds.Checked) {
                amoutDue += 60.0;
            }
            txtAmountDue.Text ="R"+ amoutDue.ToString("N2");
        }
    }
}






Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS