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

Need C# ..............in Visual Studio not C++ not java CITP3310 Assignment 7 Cr

ID: 3718769 • Letter: N

Question

Need C# ..............in Visual Studio

not C++

not java

CITP3310 Assignment 7 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 . . . 2. getData function: pass the object into this function via parameter . prompt user to enter the length and width . pro mpt 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.

Explanation / Answer

Hi Friend,

Please find my C# program.

using System;

namespace Rooms
{
   //Class that holds data related to room
   class RoomInfo
   {
       //Private variables
       private double length;
       private double width;
       private bool hasTV;
       private static double houseSize = 0;
      
       //Constructor
       public RoomInfo()
       {
           length = 0;
           width = 0;
           hasTV = false;
       }
      
       //Parameterized constructor
       public RoomInfo(double l, double w, bool tv)
       {
           length = l;
           width = w;
           hasTV = tv;
       }
      
       //Mutator methods
       public void setLength(double l)
       {
           length = l;
       }
      
       public void setWidth(double w)
       {
           width = w;
       }
      
       public void setHasTV(bool tv)
       {
           hasTV = tv;
       }
      
       public void setHouseSize(double val)
       {
           houseSize += val;
       }
      
       //Accessor Methods
       public double getHouseSize()
       {
           return houseSize;
       }
      
       public double getLength()
       {
           return length;
       }
      
       public double getWidth()
       {
           return width;
       }
      
       public bool getHasTV()
       {
           return hasTV;
       }
      
       //Method that calculates room size
       public void calcRoomSize()
       {
           double val;
           val = length * width;
          
           //Setting house size
           setHouseSize(val);
       }
   }
  
   //C# Program that tests the RoomInfo class
class RoomInfoDemo
{
static void Main()
{
           //Array of 4 room objects
           RoomInfo[] rooms = new RoomInfo[4];
          
           int i;
           int tvCnt = 0;
          
           //Reading data about each room
           for(i=0; i<4; i++)
           {
               Console.Write(" Input data of Room {0}:", (i+1));
               RoomInfo temp = new RoomInfo();
               getData(temp);
               rooms[i] = temp;
           }
          
           Console.WriteLine(" Rooms Info: ");
          
           //Printing each room size
           for(i=0; i<4; i++)
           {
               Console.WriteLine(" Room {0} Size: {1} Sft", (i+1), (rooms[i].getLength() * rooms[i].getWidth()));
               if((rooms[i].getHasTV()) == true)
                   tvCnt++;
           }
          
           //Printing house size
           Console.WriteLine(" House Size: {0} Sft ", rooms[0].getHouseSize());
          
           //Printing number of rooms that has Tv
           Console.WriteLine(" Number of rooms that has TV: {0} ", tvCnt);
          
           Console.WriteLine(" Press any key to exit.");
Console.ReadKey();
}
      
       //Method that reads data from user about Room
       static void getData(RoomInfo obj)
       {
           double l, w;
           char tv;
           bool hastv;
          
           //Reading length
           Console.Write(" Enter length (in ft): ");
           l = Convert.ToDouble(Console.ReadLine());
          
           //Reading width
           Console.Write(" Enter width (in ft): ");
           w = Convert.ToDouble(Console.ReadLine());
          
           //Reading tv status
           Console.Write(" Input Y if there is a TV in the room or N if there is no TV: ");
           tv = Console.ReadKey().KeyChar;
          
           //Updating hasTv
           if(tv.Equals('Y'))
               hastv = true;
           else
               hastv = false;
              
           //Setting values  
           obj.setLength(l);
           obj.setWidth(w);
           obj.setHasTV(hastv);
           obj.calcRoomSize();
       }
}
}

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