USING VISUAL BASIC STUDIO PLEASE PROVIDE THE CODE IN C# LANGUAGE SELECT CONSOLE APPLICATION
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**
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. 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).
using System;
public class Room
{
private double L;
private double W;
public Room(double L,double W) //constructor
{
this.L = L;
this.W = W;
}
//get methods
public double getL()
{
return L;
}
public double getW()
{
return W;
}
//area method
public double area()
{
return L*W;
}
}
public class House
{
private Room room1;
private Room room2;
public House(Room room1,Room room2) //constructor with objects as arguments
{
this.room1 = room1;
this.room2 = room2;
}
//compare two rooms using their areas
public bool biggerRoom()
{
if( room1.area() > room2.area())
return true; //return true if room1 is bigger than room2
else
return false;
}
}
public class Test
{
public static void Main()
{
double l,w;
Console.WriteLine("Enter the Length and Width of Room 1 : ");
l = Convert.ToDouble(Console.ReadLine());
w = Convert.ToDouble(Console.ReadLine());
Room r1 = new Room(l,w);
Console.WriteLine("\nEnter the Length and Width of Room 2 : ");
l = Convert.ToDouble(Console.ReadLine());
w = Convert.ToDouble(Console.ReadLine());
Room r2 = new Room(l,w);
House h = new House(r1,r2);
if(h.biggerRoom())
Console.WriteLine("\nparents get room #1 of size "+ r1.area()+ " children get room #2 of size "+r2.area()+".");
else
Console.WriteLine("\nparents get room #2 of size "+ r2.area()+ " children get room #1 of size "+r1.area()+".");
}
}
Output:
Enter the Length and Width of Room 1 : 23.4 44.3 Enter the Length and Width of Room 2 :
32.1 46.7
parents get room #2 of size 1499.07 children get room #1 of size 1036.62.
USING VISUAL BASIC STUDIO PLEASE PROVIDE THE CODE IN C# LANGUAGE SELECT CONSOLE APPLICATION You are...
Language is C++ Basic principles and theory of structured programming in C++ by implementing the class: Matrix Use these principles and theory to help build and manipulate instances of the class (objects), call member functions Matrix class implementation from the main function file and, in addition, the Matrix class must have its interface(Matrix.h) in a separate file from its implementation (Matrix.cpp). The code in the following files: matrix.h matrix.cpp matrixDriver.h Please use these file names exactly. Summary Create three files...
PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: 1. Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. 2. A non-argument constructor method to create a default rectangle. 3. Another constructor method to...
This code is in java. Create a Java class that has the private double data of length, width, and price. Create the gets and sets methods for the variables. Create a No-Arg constructor and a constructor that accepts all three values. At the end of the class add a main method that accepts variables from the user as input to represent the length and width of a room in feet and the price of carpeting per square foot in dollars...
Recursion program C++. Visual Studio Win 32 console application that has user loop. The Design a computer program a executes the program, should do the following. computer, as it 1) The computer should politely ask the user for two input integers m and n. There should be code to make sure that m <-n 2) Then there should be a recursive function, called LargestToSmallestO that is invoked to output all the values from n downto m. 3) Then there should...
PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Program 2: Design (pseudocode) and implement (source code) a class called Counter. It should have one private instance variable representing the value of the counter. It should have two instance methods: increment() which adds on to the counter value and getValue() which returns the current value. After creating the Counter class, create a program that simulates tossing a coin 100 times using two Counter objects (Head...
Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The main form contains a reset button and sets the form's background colour according to the colour values indicated by the colour control objects. Each colour control object is controlled by a corresponding colour control form which provides a progress bar to show the value (in the range 0 to 255) of the corresponding colour control object. The user can click the increase (+) or...
C# assistance please help Write the source code for a C# program (i.e., a separate class) named “BookDemo” that uses the Book class below and does the following in the Main method of BookDemo: 1) Declare local variables for book title and author, and initialize the variables to “C# Programming” and “Farrell” 2) Instantiate a Book object using the information from Step 1 3) Print the summary of the book object using the displaySummary() method in the Book class class...
c++ please Assignment Write a program that calculates the quality of a home composed of three rooms. For each room, the user will give the width and depth information as two doubles, the unusable amount of space within the room as a double, the fact that the door opens inward or outward as a boolean (1 means inward), and the number of windows as an integer. Based on this information the program should calculate the total usable size of the...
Please write below code in C++ using Visual Studio. Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...