Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Using Visual Studio 2017, create a new C# console application In this lab, you will create a program that reads information about different rectangles from
Using Visual Studio 2017, create a new C# console application
In this lab, you will create a program that reads information about different rectangles from an input file, and then prints information about each one to the screen 1) Using Visual Studio 2017, create a new C# console application (.NET Framework). Add a new class (by right-clicking on the project name in the solution explorer, choosing "Add". and then choosing "Class". Name your class Rectangle.cs. In the code for the Rectangle class, include the following length and width fields (you can assume these will be integers) a constructor that takes values for both fields, and initializes them an Area method that returns the area of this Rectangle the method: public override string ToString) that returns a string that looks like this when printed 3x4 rectangle Area: 12 Your ToString method should make use of the area method 2) Navigate to the folder Visual Studio created for your lab. If you named it "Lab11", then that would be the name of the folder. Inside that folder will be another folder called "Lab11" - - open it, too. Open the bin folder, and then open the Debug folder. In the Debug folder, right-click and select "New" and then "Text Document". Name the text file "dims.txt" (it will already have a.txt extension, so you should only need to type "dims" for the name. Open the dims.txt file and write the following lines: 5 6 1 12 7 2 3) Rename the Program.cs file to Lab11.cs. Open the Lab11 file, which should already contain the Main method. Make sure you rename the class declaration to say "Lab11" instead of "Program". In the Main method for that class Create a StreamReader to connect to the dims.txt file Create a new List that can hold Rectangle objects Read each line in the file with a while loop Use Split to extract the numbers on each line - the first is the length of a Rectangle, and the second is the width Create a new Rectangle object from the length and width you read in, and add it to your List Close the connection to the file Use a foreach loop through your List to print each Square by calling its ToString methodStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started