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

Using C# Previously you created a program for Marshall\'s Murals that prompts a

ID: 3788528 • Letter: U

Question

Using C#

Previously you created a program for Marshall's Murals that prompts a user for the number of interior and exterior murals scheduled to be painted during the next month. The program computes the expected revenue for each type of mural when interior murals cost $500 each and exterior murals cost $750 each. The application should display, by mural type, the number of murals ordered, the cost for each type, and a subtotal. The application also displays the total expected revenue and a statement that indicates whether more interior murals are scheduled than exterior ones. Now create an interactive GUI program named MarshallsRevenueGUI that performs all the same tasks.

Explanation / Answer

Program.cs

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

namespace MarshallsRevenueGUI
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new frmMarshallsRevenue());
        }
    }
}

frmMarshallsRevenue.Designer.cs


namespace MarshallsRevenueGUI
{
    partial class frmMarshallsRevenue
    {
        /// <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.lblNumbInteriorMurals = new System.Windows.Forms.Label();
            this.lblNumbExteriorMurals = new System.Windows.Forms.Label();
            this.txtNumbInteriorMurals = new System.Windows.Forms.TextBox();
            this.txtNumbExteriorMurals = new System.Windows.Forms.TextBox();
            this.lblCostInterior = new System.Windows.Forms.Label();
            this.lblCostExterior = new System.Windows.Forms.Label();
            this.lblInstructions02 = new System.Windows.Forms.Label();
            this.lblRevenueTotal = new System.Windows.Forms.Label();
            this.lblSchedulingRemarks = new System.Windows.Forms.Label();
            this.txtRevenueInterior = new System.Windows.Forms.TextBox();
            this.txtRevenueExterior = new System.Windows.Forms.TextBox();
            this.txtRevenueTotal = new System.Windows.Forms.TextBox();
            this.lblInstructions01 = new System.Windows.Forms.Label();
            this.txtMonth = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            //
            // lblNumbInteriorMurals
            //
            this.lblNumbInteriorMurals.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblNumbInteriorMurals.Location = new System.Drawing.Point(36, 57);
            this.lblNumbInteriorMurals.Name = "lblNumbInteriorMurals";
            this.lblNumbInteriorMurals.Size = new System.Drawing.Size(160, 15);
            this.lblNumbInteriorMurals.TabIndex = 0;
            this.lblNumbInteriorMurals.Text = "Number of Interior Murals:";
            this.lblNumbInteriorMurals.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // lblNumbExteriorMurals
            //
            this.lblNumbExteriorMurals.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblNumbExteriorMurals.Location = new System.Drawing.Point(36, 83);
            this.lblNumbExteriorMurals.Name = "lblNumbExteriorMurals";
            this.lblNumbExteriorMurals.Size = new System.Drawing.Size(160, 15);
            this.lblNumbExteriorMurals.TabIndex = 1;
            this.lblNumbExteriorMurals.Text = "Number of Exterior Murals:";
            this.lblNumbExteriorMurals.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // txtNumbInteriorMurals
            //
            this.txtNumbInteriorMurals.Location = new System.Drawing.Point(202, 54);
            this.txtNumbInteriorMurals.Name = "txtNumbInteriorMurals";
            this.txtNumbInteriorMurals.Size = new System.Drawing.Size(40, 20);
            this.txtNumbInteriorMurals.TabIndex = 2;
            this.txtNumbInteriorMurals.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtNumbInteriorMurals.TextChanged += new System.EventHandler(this.txtNumbInteriorMurals_TextChanged);
            //
            // txtNumbExteriorMurals
            //
            this.txtNumbExteriorMurals.Location = new System.Drawing.Point(202, 80);
            this.txtNumbExteriorMurals.Name = "txtNumbExteriorMurals";
            this.txtNumbExteriorMurals.Size = new System.Drawing.Size(40, 20);
            this.txtNumbExteriorMurals.TabIndex = 4;
            this.txtNumbExteriorMurals.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtNumbExteriorMurals.TextChanged += new System.EventHandler(this.txtNumbExteriorMurals_TextChanged);
            //
            // lblCostInterior
            //
            this.lblCostInterior.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblCostInterior.Location = new System.Drawing.Point(248, 57);
            this.lblCostInterior.Name = "lblCostInterior";
            this.lblCostInterior.Size = new System.Drawing.Size(110, 15);
            this.lblCostInterior.TabIndex = 4;
            this.lblCostInterior.Text = "costInterior";
            this.lblCostInterior.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // lblCostExterior
            //
            this.lblCostExterior.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblCostExterior.Location = new System.Drawing.Point(248, 83);
            this.lblCostExterior.Name = "lblCostExterior";
            this.lblCostExterior.Size = new System.Drawing.Size(110, 15);
            this.lblCostExterior.TabIndex = 5;
            this.lblCostExterior.Text = "costExterior";
            this.lblCostExterior.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
            //
            // lblInstructions02
            //
            this.lblInstructions02.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblInstructions02.Location = new System.Drawing.Point(12, 30);
            this.lblInstructions02.Name = "lblInstructions02";
            this.lblInstructions02.Size = new System.Drawing.Size(420, 18);
            this.lblInstructions02.TabIndex = 6;
            this.lblInstructions02.Text = "2. Enter the number of murals scheduled to be painted for this month:";
            //
            // lblRevenueTotal
            //
            this.lblRevenueTotal.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblRevenueTotal.Location = new System.Drawing.Point(211, 107);
            this.lblRevenueTotal.Name = "lblRevenueTotal";
            this.lblRevenueTotal.Size = new System.Drawing.Size(150, 15);
            this.lblRevenueTotal.TabIndex = 7;
            this.lblRevenueTotal.Text = "Total Expected Revenue:";
            this.lblRevenueTotal.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            //
            // lblSchedulingRemarks
            //
            this.lblSchedulingRemarks.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblSchedulingRemarks.ForeColor = System.Drawing.SystemColors.Highlight;
            this.lblSchedulingRemarks.Location = new System.Drawing.Point(36, 133);
            this.lblSchedulingRemarks.Name = "lblSchedulingRemarks";
            this.lblSchedulingRemarks.Size = new System.Drawing.Size(410, 60);
            this.lblSchedulingRemarks.TabIndex = 8;
            this.lblSchedulingRemarks.Text = "schedulingRemarks";
            //
            // txtRevenueInterior
            //
            this.txtRevenueInterior.Enabled = false;
            this.txtRevenueInterior.Location = new System.Drawing.Point(367, 54);
            this.txtRevenueInterior.Name = "txtRevenueInterior";
            this.txtRevenueInterior.Size = new System.Drawing.Size(80, 20);
            this.txtRevenueInterior.TabIndex = 3;
            this.txtRevenueInterior.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            //
            // txtRevenueExterior
            //
            this.txtRevenueExterior.Enabled = false;
            this.txtRevenueExterior.Location = new System.Drawing.Point(367, 80);
            this.txtRevenueExterior.Name = "txtRevenueExterior";
            this.txtRevenueExterior.Size = new System.Drawing.Size(80, 20);
            this.txtRevenueExterior.TabIndex = 5;
            this.txtRevenueExterior.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            //
            // txtRevenueTotal
            //
            this.txtRevenueTotal.Enabled = false;
            this.txtRevenueTotal.Location = new System.Drawing.Point(367, 106);
            this.txtRevenueTotal.Name = "txtRevenueTotal";
            this.txtRevenueTotal.Size = new System.Drawing.Size(80, 20);
            this.txtRevenueTotal.TabIndex = 6;
            this.txtRevenueTotal.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            //
            // lblInstructions01
            //
            this.lblInstructions01.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblInstructions01.Location = new System.Drawing.Point(12, 9);
            this.lblInstructions01.Name = "lblInstructions01";
            this.lblInstructions01.Size = new System.Drawing.Size(270, 18);
            this.lblInstructions01.TabIndex = 12;
            this.lblInstructions01.Text = "1. Select the month being scheduled (1-12):";
            //
            // txtMonth
            //
            this.txtMonth.Location = new System.Drawing.Point(288, 7);
            this.txtMonth.Name = "txtMonth";
            this.txtMonth.Size = new System.Drawing.Size(40, 20);
            this.txtMonth.TabIndex = 13;
            this.txtMonth.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
            this.txtMonth.TextChanged += new System.EventHandler(this.txtMonth_TextChanged);
            //
            // frmMarshallsRevenue
            //
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(459, 207);
            this.Controls.Add(this.txtMonth);
            this.Controls.Add(this.lblInstructions01);
            this.Controls.Add(this.txtRevenueTotal);
            this.Controls.Add(this.txtRevenueExterior);
            this.Controls.Add(this.txtRevenueInterior);
            this.Controls.Add(this.lblSchedulingRemarks);
            this.Controls.Add(this.lblRevenueTotal);
            this.Controls.Add(this.lblInstructions02);
            this.Controls.Add(this.lblCostExterior);
            this.Controls.Add(this.lblCostInterior);
            this.Controls.Add(this.txtNumbExteriorMurals);
            this.Controls.Add(this.txtNumbInteriorMurals);
            this.Controls.Add(this.lblNumbExteriorMurals);
            this.Controls.Add(this.lblNumbInteriorMurals);
            this.Name = "frmMarshallsRevenue";
            this.Text = "Marshall's Revenue GUI";
            this.Load += new System.EventHandler(this.frmMarshallsRevenue_Load);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        #endregion

        private System.Windows.Forms.Label lblNumbInteriorMurals;
        private System.Windows.Forms.Label lblNumbExteriorMurals;
        private System.Windows.Forms.TextBox txtNumbInteriorMurals;
        private System.Windows.Forms.TextBox txtNumbExteriorMurals;
        private System.Windows.Forms.Label lblCostInterior;
        private System.Windows.Forms.Label lblCostExterior;
        private System.Windows.Forms.Label lblInstructions02;
        private System.Windows.Forms.Label lblRevenueTotal;
        private System.Windows.Forms.Label lblSchedulingRemarks;
        private System.Windows.Forms.TextBox txtRevenueInterior;
        private System.Windows.Forms.TextBox txtRevenueExterior;
        private System.Windows.Forms.TextBox txtRevenueTotal;
        private System.Windows.Forms.Label lblInstructions01;
        private System.Windows.Forms.TextBox txtMonth;
    }
}


frmMarshallsRevenue.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 MarshallsRevenueGUI
{
    public partial class frmMarshallsRevenue : Form
    {
        // define class global variables
        int intMonth;
        int intMuralsInterior = 0;
        int intMuralsExterior = 0;
        double dblCostInterior = 500.00;
        double dblCostInteriorDiscounted = 450.00;
        double dblCostExterior = 750.00;
        double dblCostExteriorDiscounted = 699.00;
        double dblRevenue = 0.00;
        String strFeedback = "";
        bool boolBypassUpdate = false;

        // initialize
        public frmMarshallsRevenue()
        {
            InitializeComponent();
            updateDisplay();
        }

        private void frmMarshallsRevenue_Load(object sender, EventArgs e)
        {

        }

        // capture input on number of month being computed
        private void txtMonth_TextChanged(object sender, EventArgs e)
        {
            if ( txtMonth.Text != "" )
            {
                // parse input to Int32, handle non-numeric input
                if ( ! Int32.TryParse(txtMonth.Text, out intMonth) )
                {
                    txtMonth.Text = "";
                    intMonth = 0;
                }
                // TO DO!!! handle out-of-range input

            }
            else
            {
                intMonth = 0;
            }
            updateDisplay();
        }

        // capture input on number of interior murals
        private void txtNumbInteriorMurals_TextChanged(object sender, EventArgs e)
        {
            if( txtNumbInteriorMurals.Text != "" )
            {
                // parse input to Int32, handle non-numeric input
                if( ! Int32.TryParse(txtNumbInteriorMurals.Text, out intMuralsInterior) )
                {
                    txtNumbInteriorMurals.Text = "";
                    intMuralsInterior = 0;
                }
                // TO DO!!! handle out-of-range input

            }
            else
            {
                intMuralsInterior = 0;
            }
            updateDisplay();
        }

        // capture input on number of exterior murals
        private void txtNumbExteriorMurals_TextChanged(object sender, EventArgs e)
        {
            if ( ! boolBypassUpdate ) {
                if (txtNumbExteriorMurals.Text != "")
                {
                    // parse input to Int32, handle non-numeric input
                    if (!Int32.TryParse(txtNumbExteriorMurals.Text, out intMuralsExterior))
                    {
                        txtNumbExteriorMurals.Text = "";
                        intMuralsExterior = 0;
                    }
                    // TO DO!!! handle out-of-range input

                }
                else
                {
                    intMuralsExterior = 0;
                }
                updateDisplay();
            }
        }

        // update form display
        private void updateDisplay()
        {
            // initialize
            strFeedback = "";
            dblRevenue = 0.00;
            // clear revenue displays
            lblCostInterior.Text = "";
            txtRevenueInterior.Text = "";
            lblCostExterior.Text = "";
            txtRevenueExterior.Text = "";
            txtRevenueTotal.Text = "";
            // compute revenue and provide feedback
            if ( intMonth != 0 )
            {
                // account for winter months
                //      exterior murals cannot be painted December (12) through February (2)
                if ( intMonth <= 2 || intMonth == 12 )
                {
                    if ( intMuralsExterior > 0 )
                    {
                        strFeedback += "Unable to complete exterior murals due to winter weather. ";
                        boolBypassUpdate = true;
                        txtNumbExteriorMurals.Text = "0";
                        intMuralsExterior = 0;
                    }
                    boolBypassUpdate = false;
                }

                // account for exterior mural discount
                //      Marshall prefers painting exterior murals during April (4), May (5), September (9) and October (10) (apply discount)
                if ( intMonth == 4 || intMonth == 5 || intMonth == 9 || intMonth == 10 )
                {
                    lblCostExterior.Text = "x " + dblCostExteriorDiscounted.ToString("C2") + " each";
                    txtRevenueExterior.Text = ((double)intMuralsExterior * dblCostExteriorDiscounted).ToString("C2");
                    dblRevenue += (double)intMuralsExterior * dblCostExteriorDiscounted;
                    strFeedback += "Discount applied to exterior murals. ";
                }
                else
                {
                    lblCostExterior.Text = "x " + dblCostExterior.ToString("C2") + " each";
                    txtRevenueExterior.Text = ((double)intMuralsExterior * dblCostExterior).ToString("C2");
                    dblRevenue += (double)intMuralsExterior * dblCostExterior;
                }

                // account for interior mural discount
                //      Marshall prefers painting interior murals during July (7) and August (8) (apply discount)
                if ( intMonth == 7 || intMonth == 8 )
                {
                    lblCostInterior.Text = "x " + dblCostInteriorDiscounted.ToString("C2") + " each";
                    txtRevenueInterior.Text = ((double)intMuralsInterior * dblCostInteriorDiscounted).ToString("C2");
                    dblRevenue += (double)intMuralsInterior * dblCostInteriorDiscounted;
                    strFeedback += "Discount applied to interior murals. ";
                }
                else
                {
                    lblCostInterior.Text = "x " + dblCostInterior.ToString("C2") + " each";
                    txtRevenueInterior.Text = ((double)intMuralsInterior * dblCostInterior).ToString("C2");
                    dblRevenue += (double)intMuralsInterior * dblCostInterior;
                }

                // update total revenue
                txtRevenueTotal.Text = dblRevenue.ToString("C2");

                // compare interior versus exterior scheduled, update feedback
                if( intMuralsInterior > intMuralsExterior )
                {
                    strFeedback += "More Interior Murals Projected than Exterior Murals. ";
                }
                else if( intMuralsInterior < intMuralsExterior )
                {
                    strFeedback += "More Exterior Murals Projected than Interior Murals. ";
                }
                else // same number scheduled
                {
                    if ( intMuralsInterior == 0 ) // no murals secheduled
                    {
                        strFeedback = "No Murals Projected. ";
                    }
                    else
                    {
                        strFeedback += "Same Number of Interior and Exterior Murals Projected. ";
                    }
                }
            }
            else
            {
                strFeedback = "You must enter a month!";
            }
            lblSchedulingRemarks.Text = strFeedback;
        }
    }
}

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