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

You are to create a House with 2 rooms in the house. The following is an example

ID: 3871010 • Letter: Y

Question

You are to create a House with 2 rooms in the house. The following is an example of C++ code for the basic classes: **in C#, it may be written differently**. Must be written in C#.

class Room

{

private:

double L;

double W;

public:

//functions go here.

}

class House

{

private:

Room room1;

Room room2;

public:

//functions go here

}

The code above is C++ version. In C#, you must make the variables private. Look up in the book if you have difficulty with this assignment and dont forget to use the "new" command. Basic Example: House h = new House();

*Make sure each class is in its own file with the correct functions and data types*

The program will basically ask the user to input a L and W for a room, then ask for L and W for the other room. It will then calculate which of the two rooms is bigger. It should assign the bigger room to the parents and smaller room to children. State: "parents get room #_ of size __", "children get room #_ of size __".

Make sure to actually use the class objects for this program. Not using the object will result in a zero. (this means the class object has functions which have access to the private variables of the class, use them)

Explanation / Answer

using System;

public class House

{ private Room room1;

private Room room2;

public static void Main()

{

House house = new House();

Console.WriteLine("Please input the length of Room1: ");

house.room1.L= Convert.ToDouble(Console.ReadLine());

Console.WriteLine("Please input the width of Room1: ");

house.room1.W= Double.Parse(Console.ReadLine());

double area1= house.room1.area();

Console.WriteLine("Please input the length of Room2: ");

house.room2.L= Double.Parse(Console.ReadLine());

Console.WriteLine("Please input the width of Room2: ");

house.room2.W= Double.Parse(Console.ReadLine());

double area2 =house.room2.area();

if (area1> area2)

{

Console.WriteLine("Parents get room #1 of size {0} ", area1);

Console.WriteLine("Children get room #2 of size {0}", area2);

}

else

{

Console.WriteLine("Parents get room #2 of size {0} ", area2);

Console.WriteLine("Children get room #1 of size {0}", area1);

}

}

}

class Room

{

private double l;

private double w;

  

public double area()

{

return l*w;

}

public double L

{

get { return this.l; }

set { l = value; }

}

public double W

{

get { return this.w; }

set { w = value; }

}

}

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