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

Need it in Visual 12 C# Not Java and not C++ The following Homework assignment h

ID: 3907338 • Letter: N

Question

Need it in Visual 12 C# Not Java and not C++

The following Homework assignment has you creating the Main class, the House class and the Room class. In the main, you will create and work with a House object. The house object has a few rooms in it as objects. The rooms have a Length, Width, and a TV variable which is true or false if there is a TV in that room.
*Make sure each class is in its own file with the correct Methods, constructors and data types*
**This assignment does not use Inheritance**

The Room class has the following private variables:
double width; double length; bool TV; The constructor of the Room class should assign random values for all 3 variables. The range for the width and length is 10-25.

The House class has the following private variables:
Room topRooms[]; Room bottomRooms[]; The constructors for the House class will ask the user how many rooms are on the top floor and how many are on the bottom floor. In the case of the overloaded constructor, the total number of rooms comes from the main while on the default constructor you should ask the user. Make sure the number of rooms on bottom and on top add up to the total number of rooms..if not, you should have them re-enter these values. Make sure you create the actual rooms at this point by using the Room’s default constructor.

In the main, you should ask first for the number of rooms in the house (1-6 rooms only). Create the house object at this point, passing the variable to the overloaded constructor for house which accepts this variable as the only parameter.
Display all top floor Room dimensions and Areas along with if a TV is in that room. Display all bottom floor Room dimensions and Areas along with if a TV is in that room.
Your program should ask the user for preferred location of room, top or bottom floor. Display to the user the room with the largest area in that floor.
Finally, display how many TVs are in the house and display this number.
* I did not specify which Methods or Properties to use, so you should define all the properties you can and methods to access the data required. A good portion of your grade is to ensure these are written and used correctly. *
When you are done, compress the folder and attach it. *Right click folder, Send To, Compressed (zipped) folder* Need it in Visual 12 C# Not Java and not C++

The following Homework assignment has you creating the Main class, the House class and the Room class. In the main, you will create and work with a House object. The house object has a few rooms in it as objects. The rooms have a Length, Width, and a TV variable which is true or false if there is a TV in that room.
*Make sure each class is in its own file with the correct Methods, constructors and data types*
**This assignment does not use Inheritance**

The Room class has the following private variables:
double width; double length; bool TV; The constructor of the Room class should assign random values for all 3 variables. The range for the width and length is 10-25.

The House class has the following private variables:
Room topRooms[]; Room bottomRooms[]; The constructors for the House class will ask the user how many rooms are on the top floor and how many are on the bottom floor. In the case of the overloaded constructor, the total number of rooms comes from the main while on the default constructor you should ask the user. Make sure the number of rooms on bottom and on top add up to the total number of rooms..if not, you should have them re-enter these values. Make sure you create the actual rooms at this point by using the Room’s default constructor.

In the main, you should ask first for the number of rooms in the house (1-6 rooms only). Create the house object at this point, passing the variable to the overloaded constructor for house which accepts this variable as the only parameter.
Display all top floor Room dimensions and Areas along with if a TV is in that room. Display all bottom floor Room dimensions and Areas along with if a TV is in that room.
Your program should ask the user for preferred location of room, top or bottom floor. Display to the user the room with the largest area in that floor.
Finally, display how many TVs are in the house and display this number.
* I did not specify which Methods or Properties to use, so you should define all the properties you can and methods to access the data required. A good portion of your grade is to ensure these are written and used correctly. *
When you are done, compress the folder and attach it. *Right click folder, Send To, Compressed (zipped) folder* Need it in Visual 12 C# Not Java and not C++

The following Homework assignment has you creating the Main class, the House class and the Room class. In the main, you will create and work with a House object. The house object has a few rooms in it as objects. The rooms have a Length, Width, and a TV variable which is true or false if there is a TV in that room.
*Make sure each class is in its own file with the correct Methods, constructors and data types*
**This assignment does not use Inheritance**

The Room class has the following private variables:
double width; double length; bool TV; The constructor of the Room class should assign random values for all 3 variables. The range for the width and length is 10-25.

The House class has the following private variables:
Room topRooms[]; Room bottomRooms[]; The constructors for the House class will ask the user how many rooms are on the top floor and how many are on the bottom floor. In the case of the overloaded constructor, the total number of rooms comes from the main while on the default constructor you should ask the user. Make sure the number of rooms on bottom and on top add up to the total number of rooms..if not, you should have them re-enter these values. Make sure you create the actual rooms at this point by using the Room’s default constructor.

In the main, you should ask first for the number of rooms in the house (1-6 rooms only). Create the house object at this point, passing the variable to the overloaded constructor for house which accepts this variable as the only parameter.
Display all top floor Room dimensions and Areas along with if a TV is in that room. Display all bottom floor Room dimensions and Areas along with if a TV is in that room.
Your program should ask the user for preferred location of room, top or bottom floor. Display to the user the room with the largest area in that floor.
Finally, display how many TVs are in the house and display this number.
* I did not specify which Methods or Properties to use, so you should define all the properties you can and methods to access the data required. A good portion of your grade is to ensure these are written and used correctly. *
When you are done, compress the folder and attach it. *Right click folder, Send To, Compressed (zipped) folder*

Explanation / Answer

Room.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace CSharpProject

{

    class Room

    {

        // Creating the private variables

        private double width;

        private double length;

        private bool tv;

       

        public Room(double width, double length, bool tv)

        {

            // Assigning values to variables

            this.width = width;

            this.length = length;

            this.tv = tv;

        }

        public double get_width()

        {

            // Returning the room width

            return width;

        }

        public double get_length()

        {

            // Returning the room length

            return length;

        }

        public bool has_tv()

        {

            // Returning whether teh romm has tv or not

            return tv;

        }

    }

}

// ----------------------------------------------------------------------------------------------------------------------------------

House.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace CSharpProject

{

    class House

    {

        // Creating top and bottom rooms array

        private Room[] topRooms;

        private Room[] bottomRooms;

        // Creating a random object for passing random values

        Random random = new Random();

        double min_val = 10; // min width/length

        double max_val = 25; // max width/length

        public House()

        {

            // Asking the user for top and bottom floors' rooms

            Console.WriteLine("How many rooms are on the top floor: ");

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

            Console.WriteLine("How many rooms are on the bottom floor: ");

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

            // Creating the rooms for top and bottom floors

            topRooms = new Room[no_of_top_rooms];

            bottomRooms = new Room[no_of_bottom_rooms];

            for (int i = 0; i < no_of_top_rooms; i++)

            {

                double width = random.NextDouble() * (max_val - min_val) + min_val;

                double length = random.NextDouble() * (max_val - min_val) + min_val;

                bool tv = random.Next(0, 2) == 0;

                topRooms[i] = new Room(width, length, tv);

            }

            for (int i = 0; i < no_of_bottom_rooms; i++)

            {

                double width = random.NextDouble() * (max_val - min_val) + min_val;

                double length = random.NextDouble() * (max_val - min_val) + min_val;

                bool tv = random.Next(0, 2) == 0;

                bottomRooms[i] = new Room(width, length, tv);

            }

        }

        public House(int total_rooms)

        {

            while (true)

            {

                // Asking the user for top and bottom floors' rooms until sum of user provided top and bottom

                // number of rooms is not equal to total rooms

                Console.WriteLine("How many rooms are on the top floor: ");

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

                Console.WriteLine("How many rooms are on the bottom floor: ");

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

                if (total_rooms != no_of_top_rooms + no_of_bottom_rooms)

                {

                    // If sum of user provided top and bottom number of rooms is not equal to total rooms,

                    // again prompt the user

                    continue;

                }

                // Creating the rooms for top and bottom floors

                topRooms = new Room[no_of_top_rooms];

                bottomRooms = new Room[no_of_bottom_rooms];

                for (int i=0; i<no_of_top_rooms; i++)

                {

                    // generating random values for width, length and tv

                    double width = random.NextDouble() * (max_val - min_val) + min_val;

                    double length = random.NextDouble() * (max_val - min_val) + min_val;

                    bool tv = random.Next(0, 2) == 0;

                    topRooms[i] = new Room(width, length, tv);

                }

                for (int i = 0; i < no_of_bottom_rooms; i++)

                {

                    // generating random values for width, length and tv

                    double width = random.NextDouble() * (max_val - min_val) + min_val;

                    double length = random.NextDouble() * (max_val - min_val) + min_val;

                    bool tv = random.Next(0, 2) == 0;

                    bottomRooms[i] = new Room(width, length, tv);

                }

                // Coming out of the loop if valid inputs are provided

                break;

            }

        }

        public Room[] get_top_rooms()

        {

            // Return the array of top floor rooms

            return topRooms;

        }

        public Room[] get_bottom_rooms()

        {

            // Return the array of bottom floor rooms

            return bottomRooms;

        }

    }

}

// ----------------------------------------------------------------------------------------------------------------------------------

MainClass.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace CSharpProject

{

    class MainClass

    {

        public static void Main(String[] args)

        {

            // Creating total rooms

            Console.WriteLine("How many rooms are needed in the house:");

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

            House house = new House(total_rooms);

            // printing top floor rooms' info

            int total_tvs = 0;

            Console.WriteLine("-------------------------");

            Console.WriteLine("Top Floor Rooms:");

            Console.WriteLine("-------------------------");

            int count = 1;

            foreach (Room room in house.get_top_rooms())

            {

                Console.WriteLine(" Room " + count + ": ");

                Console.WriteLine("Lenght: " + room.get_length());

                Console.WriteLine("Width: " + room.get_width());

                Console.WriteLine("Tv present: " + room.has_tv());

                count++;

                if (room.has_tv())

                {

                    total_tvs++;

                }

            }

            // printing top floor rooms' info

            Console.WriteLine("-------------------------");

            Console.WriteLine("Bottom Floor Rooms:");

            Console.WriteLine("-------------------------");

            count = 1;

            foreach (Room room in house.get_bottom_rooms())

            {

                Console.WriteLine(" Room " + count + ": ");

                Console.WriteLine("Lenght: " + room.get_length());

                Console.WriteLine("Width: " + room.get_width());

                Console.WriteLine("Tv present: " + room.has_tv());

                count++;

                if (room.has_tv())

                {

                    total_tvs++;

                }

            }

            // Asking user the preffered floor

            Console.WriteLine(" On which floor do you want a room (Top/Bottom): ");

            string floor = Console.ReadLine().ToLower();

            Room[] rooms = null;

            if (floor.Equals("top"))

            {

                rooms = house.get_top_rooms();

            }

            else if (floor.Equals("bottom"))

            {

                rooms = house.get_bottom_rooms();

            }

            // Getting the room with max area

            Room max_room = rooms[0];

            double max_area = 0;

            foreach (Room room in rooms)

            {

               double room_area = room.get_length() * room.get_width();

                if (room_area > max_area)

                {

                    max_room = room;

                    max_area = room_area;

                }

            }

            // Printing the room with max area

            Console.WriteLine("-------------------------");

            Console.WriteLine(" Room with max area: ");

            Console.WriteLine("-------------------------");

            Console.WriteLine("Lenght: " + max_room.get_length());

            Console.WriteLine("Width: " + max_room.get_width());

            Console.WriteLine("Tv present: " + max_room.has_tv());

            // Printing the total tv present in house

            Console.WriteLine(" Total TVs in the house are " + total_tvs);

        }

    }

}

OUTPUT

How many rooms are needed in the house:

5

How many rooms are on the top floor:

4

How many rooms are on the bottom floor:

5

How many rooms are on the top floor:

2

How many rooms are on the bottom floor:

9

How many rooms are on the top floor:

2

How many rooms are on the bottom floor:

3

-------------------------

Top Floor Rooms:

-------------------------

Room 1:

Lenght: 13.9515398670694

Width: 14.1321587325689

Tv present: True

Room 2:

Lenght: 15.990696109827

Width: 20.5416689419847

Tv present: False

-------------------------

Bottom Floor Rooms:

-------------------------

Room 1:

Lenght: 11.0141055244087

Width: 10.4546631781639

Tv present: False

Room 2:

Lenght: 14.1147359619451

Width: 21.1216918291159

Tv present: True

Room 3:

Lenght: 20.4242783134916

Width: 14.2898097374895

Tv present: True

On which floor do you want a room (Top/Bottom):

bottom

-------------------------

Room with max area:

-------------------------

Lenght: 14.1147359619451

Width: 21.1216918291159

Tv present: True

Total TVs in the house are 3

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