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

Microsoft Visual C# 2017 pages 303-304 Please keep these as basic as possible so

ID: 3884315 • Letter: M

Question

Microsoft Visual C# 2017 pages 303-304

Please keep these as basic as possible so that I can understand and follow how it was done.

3. Create a program named PaintingEstimate whose Main() method prompts a user for length and width of a room in feet. Create a method that accepts the values and then computes the cost of painting the room, assuming the room is rectangular and has four full walls and 9-foot ceilings. The price of the job is $6 per square foot. Return the price to the Main() method, and display it.

Math calculation to use in your method: cost = ((length * HEIGHT * 2) + (width * HEIGHT * 2)) * PRICE;

Debugging Excercise

DebugSeven2

Please fix this code so that it can run

// Address an envelope using names and addresses
// stored in two parallel arrays
using static System.Console;
class DebugSeven2
{
static void Main()
{
string[] addressees = {"Ms. Mary Mack", "Mr. Tom Thumb", "Dr. Seuss"};
string[] addresses = {"123 Main", "456 Elm", "87 Maple"};
for(int x = 0; x < addressees.Length; ++x)
AddressEnvelope(addressees[x], addresses[x]);
}
private static void AddressEnvelope(string person, string street)
{
WriteLine("To : {0}", person);
WriteLine(" {1}", street);
for(x = 0; x < 30; ++x)
Write("-");
WriteLine();
}
}

The Results for both should look like this:

Explanation / Answer

first Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter length of the room :");
            int length = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter width of the room :");
            int width = Convert.ToInt32(Console.ReadLine());
            double cost = ((length * 9 * 2) + (width * 9 * 2)) * 6;
           
            Console.WriteLine("The cost of painting your room is : " + String.Format("{0:0.00}", cost));
        }
    }
}

Second Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication7
{
   
    class Program
    {
        static void Main(string[] args)
        {
            string[] addressees = { "Ms. Mary Mack", "Mr. Tom Thumb", "Dr. Seuss" };
            string[] addresses = { "123 Main", "456 Elm", "87 Maple" };
            for (int x = 0; x < addressees.Length; ++x)
                AddressEnvelope(addressees[x], addresses[x]);
        }
        private static void AddressEnvelope(string person, string street)
        {
            Console.WriteLine("To : {0}", person);
            Console.WriteLine(" {0}", street);
            for (int x = 0; x < 30; ++x)
                Console.Write("-");
            Console.WriteLine();
        }
    }
}