Answered step by step
Verified Expert Solution
Question
1 Approved Answer
we saw how to create custom classes and work with a class declaration consisting of a constructor(s), properties, getter / setter methods, etc.. We
we saw how to create custom classes and work with a class declaration consisting of a constructor(s), properties, getter / setter methods, etc.. We will leverage that knowledge in this section's work. Note the following: Launch Visual Studio 2022 (or higher) Community Edition and create a new Visual C# console-based project named p3s1_PaintingDemo on your local drive. Be sure this includes creating a folder with the same name. All remaining work in this section falls within this top-level folder. Declare a Room class. The class's constructor requires parameters named roomLength, room Width, and roomHeight. Each of these is an int data type. Create fields (instance variables) to match the parameters, naming them roomLength, room Width, and roomHeight. To assign the constructor's parameter values to the fields, the "this" keyword will be needed. Create properties, suitably named, to work with the class's fields. Only getter methods (no setter methods) for the properties should be created. These getter methods should be declared as public. In addition, create fields named area and gallons. They too are declared as an int data type. The area represents the wall area of a Room. The gallons is the number of gallons of paint needed to paint a Room. Both values are computed by calling private methods in the Room class. Name one ComputeArea() and the other ComputeGallons(). They are declared as void, but their job is to assign a value to area and to gallons. Calling these methods should be done in the Room class constructor(s). A room is assumed to have four walls, and you do not need to allow for windows and doors, and you do not need to allow for painting the ceiling. A room requires one gallon of paint for every 350 square feet (plus an extra gallon for any square feet greater than 350). In other words, a 12 x 10 x 9 room has 396 area of wall space, and so requires two gallons of paint. For reference, here are those same figures with totals shown in an Excel worksheet: A B D E 234 567 8 9 Length Height 12 9 Width Height 10 9 Side Walls Total Wall Space 216 =2*(83*C3) Front & Rear Walls Total Wall Space Formula Total Wall Space Area Formula 180-2*(B6*C6) Formula 396 =D3+D6 With the class now declared (i.e., its needed fields and methods), return to the starting class. Create a rooms array that contains eight instantiated Room objects and produces the needed results. Apply a loop to iterate the array. It should contain the logic to produce the needed output. Test your program. Model your output after the below example, but feel welcome to use room size integers other than those shown here: | Microsoft Visual Studio Debug Console Room Painting Estimating Program For a 8 X 8 X 8 foot room... two walls are 8 long and 8 high. and the other two walls are 8 long and 8 high. This makes a total wall area of 256, so you need 1 gallon(s) of paint. For a 10 X 9 X 8 foot room... two walls are 10 long and 8 high and the other two walls are 9 long and 8 high. This makes a total wall area of 384, so you need 1 gallon (s) of paint. For a 12 X 18 X 9 foot room... two walls are 12 long and 9 high and the other two walls are 10 long and 9 high. This makes a total wall area of 396, so you need 2 gallon(s) of paint. For a 14 X 11 X 9 foot room... two walls are 14 long and 9 high and the other two walls are 11 long and 9 high. This makes a total wall area of 450, so you need 2 gallon(s) of paint. For a 16 X 12 X 10 foot room... two walls are 16 long and 10 high and the other two walls are 12 long and 10 high. This makes a total wall area of 560, so you need 2 gallon(s) of paint. For a 18 X 13 X 10 foot room... two walls are 18 long and 10 high and the other two walls are 13 long and 10 high. This makes a total wall area of 620, so you need 2 gallon(s) of paint. For a 20 X 14 X 11 foot room... two walls are 20 long and 11 high and the other two walls are 14 long and 11 high. This makes a total wall area of 748, so you need 3 gallon(s) of paint. For a 22 X 15 X 11 foot room... two walls are 22 long and 11 high and the other two walls are 15 long and 11 high. This makes a total wall area of 814, so you need 3 gallon(s) of paint. Replace the comment in Program.cs that is needed to control the loop's terminating status. Edit the Student.cs file, ensuring it is error free. When executed, the program produces the following output. Test your work using various input values and not only the ones shown below: Program.cs C#start_p3s3_Debugging 1 using System; 234 68495 7 13 14 15 16 17 18 19 20 21 22 23 24 25 10 E 11 12 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 E Student.cs X namespace start_p3s3_Debugging { 8 public class Student { -0 8 private int stuIdd; private double stuGpa; public void setID() { string stuNumber; try { Write("Enter student ID: "); stuNumber = ReadLine; } catch (FormatException fe) throw (fe); } public void setGPA() { start_p3s3_Debugging. Student string stuGPAString; try { stuId = Convert.ToInt32(stuNumber); Write("Enter student GPA: "); stuGPAString = ReadLinne(); stuGPA = Convert.ToDouble(stuGPAString); catch (FormatException fe) { throw (fe6); stuldd Program.cs X Student.cs #start_p3s3_Debugging 1 Eusing System; 2345 67 7 220220020228050592832083 10 11 12 13 14 15 16 17 18 19 21 24 26 27 31 using static System.Console; Enamespace start_p3s3_Debugging B 8 B 0 references class Program { O references static void Main() { Student student1 = new Student (); bool areNumbersGood = false; while (!areNumbersGood) { start_p3s3 Debugging.Program try { student1.setID(); student1.setGPA(); // A statement is missing here. } catch (FormatException e) { Console.WriteLine(e.Message); Console.WriteLine("(Either the student ID or the GPA"); Console.WriteLine(" was not in the correct format.)"); Console.WriteLine("You will have to re-enter the student data."); Console.WriteLine("You entered a valid student."); M
Step by Step Solution
There are 3 Steps involved in it
Step: 1
It appears that your question or request is incomplete as the images youve prov...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