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

Microsoft Visual C# 2012: An introduction to object-oriented programming Ch.7 Qu

ID: 3691346 • Letter: M

Question

Microsoft Visual C# 2012: An introduction to object-oriented programming Ch.7 Question # 3

A. Create a console-based program named SidingEstimate whose Main() method holds values for the length and depth of a house and accepts values in feet for these variables from a user. Within the class, create a method that accepts the variables and then computes the cost of siding a house as length times width times $5. Return the cost to the Main() method and display it.

B. Creat a GUI application named SidingEstimateGUI that accepts a house's dimensions from a user and contains the methods described in Exercise 3a. When the user clicks a button, display the results.

Explanation / Answer

Program A

using System;

namespace houseCost

{

   class SidingEstimate

   {

      public int findValues(int length,int depth,int feet)

      {

        /* local variable declaration */

        int result;

        result = (length*breadth)*feet;

        return result;

      }

      static void Main(string[] args)

      {

         /* local variable definition */

         int length = 100;

         int depth = 200;

         Console.write("Enter how many feets do you want");

         int feet = Convert.ToInt32(Console.ReadLine());

         int ret;

         SidingEstimate n = new SidingEstimate ();

         //calling the findValues method

         ret = n.findValues(length , depth,feet);

         Console.WriteLine("Total Cost: ", ret );

         Console.ReadLine();

      }

   }}