Create a class called RoomInfo:

Need to have the following private variables for class:
length (double)
width (double)
hasTV (bool)
houseSize(static double)

Need to have following functions for class:
Constructors
Properties for each variables
calcRoomSize: this function calculate the room size and update the house size.

Create a class called RoomInfoDemo.
1. main function:
create four different room objects
call getData function for each room
Display room and house size
Display number of rooms have TV

  1. getData function:
    pass the object into this function via parameter
    prompt user to enter the length and width
    prompt user to enter: ‘Y’ if there is a TV in the room or ‘N’ if there is none, and save the
    result in the “hasTV” variable.
using System;


namespace Assignment7
{
   public class RoomInfo
   {
      private double[] lenght;// array of lenght of rooms
      private double[] width;// array of width of rooms
      private bool[] hasTV;// array of room that have TV
      private static double[] houseSize;//array of size of house 


      //declaring private variables needed
      private double Length { get; set; }  
      private double Width { get; set; }
      private bool HasTV { get; set; }
      private static double HouseSize { get; set; }


      //constructors 
      public RoomInfo(double length, double width, double houseSize, bool hasTV, double [] lenghtArray, double widthArray, double houseSizeArray, bool  hasTVArray)
      {
         Length = length; //set Length to length 
         lenght = lenghtArray;//initialize lenght array
         Width = width; //set Width to width 
         width = widthArray;//initialize width array
         HouseSize = houseSize; //set HouseSize to housesize
         houseSize = houseSizeArray;//initialize houseSizeArray array
         HasTV = hasTV; //set HasTV to hasTV 
         hasTV = hasTVArray;//initialize hasTV array
      }//end constructor      


    }
}





using System;


namespace Assignment7
{
   public class RoomInfoDemo
   {

      public double CalcRoomSize { get; set; }

      public static void Main(string[] args)
      {

         int[] lenghtArray = { };
         int[] widthArray = { };
         bool[] hasTVArray = { };
         int[] houseSize = { };


         //create RoomInfo objects
         RoomInfoDemo room1 = new RoomInfoDemo();
         RoomInfoDemo room2 = new RoomInfoDemo();
         RoomInfoDemo room3 = new RoomInfoDemo();
         RoomInfoDemo room4 = new RoomInfoDemo();


         //displays size of room
         Console.WriteLine("Room 1 size is: {0}", room1.CalcRoomSize);
         Console.WriteLine("Room 2 size is: {0}", room2.CalcRoomSize);
         Console.WriteLine("Room 3 size is: {0}", room3.CalcRoomSize);
         Console.WriteLine("Room 4 size is: {0}", room4.CalcRoomSize);



         Console.WriteLine();//blankline
         Console.ReadLine();//reads line
      }

   }
}

not sure if any of this is correct ... any help would be awesome !!!!

Your RoomInfo constructor looks a bit "heavy". Introduce other constructors beside this one, because you probably won't know the data for each room in advance. Besides, you have to write a getData function that will be needed to fill in all this data(through the properties) for a room.
What I usually use to input a double is something like this:

private double readDouble(string prompt) 
    {
        Console.Write(prompt);
        string line = Console.ReadLine();
        return double.Parse(line);
    }

Beware however there is no error checking here!
Perhaps you could try to implement that yourself?

This article has been dead for over six months. Start a new discussion instead.