I have this program that runs perfetly but receives a stylecheck error and I have no idea how to fix the error. I will attach the style check error below and the sample outputs. main.cc file #include #include "rectangle.h" int main() {   unsigned int length = 0;   unsigned int width = 0;   Rectangle r1;    Rectangle r2;   std::cout << "====== Rectangle 1 ======" << std::endl;   // ===================== YOUR CODE HERE ========================   // Accept user input for the length and width of rectangle 1,   // and instantiate a new Rectangle object with these inputs.   // =============================================================   std::cout << "Please enter the length: "; // input length   std::cin>>length;   r1.SetLength(length);   std::cout << "Please enter the width: "; // input width   std::cin>>width;   r1.SetWidth(width);   std::cout << "Rectangle 1 created with length " << r1.GetLength() << " and width " <<  r1.GetWidth() << std::endl;   std::cout << "The area of rectangle 1 is: " << r1.Area() << std::endl;   std::cout << "The perimeter of Rectangle 1 is: " << r1.Perimeter() << std::endl << std::endl;    std::cout << "====== Rectangle 2 ======" << std::endl;   // ===================== YOUR CODE HERE ========================   // Accept user input for the length and width of rectangle 2,   // and instantiate a new Rectangle object with these inputs.   // =============================================================   std::cout << "Please enter the length: ";   std::cin>>length;   r2.SetLength(length);   std::cout << "Please enter the width: ";   std::cin>>width;   r2.SetWidth(width);   std::cout << "Rectangle 2 created with length " << r2.GetLength() << " and width " << r2.GetWidth() << std::endl;   std::cout << "The area of rectangle 2 is: " << r2.Area() << std::endl;    std::cout << "The perimeter of Rectangle 2 is: " << r2.Perimeter() << std::endl << std::endl;   // ===================== YOUR CODE HERE ========================   // Call LargestRectangleByArea to determine which rectangle   // is larger, and print out its length, width, and area.   // Follow the README for formatting.   // =============================================================   Rectangle largestRectangle = LargestRectangleByArea(r1, r2);   std::cout << "The largest rectangle has a length of " << largestRectangle.GetLength() << ", a width of "    << largestRectangle.GetWidth() << ", and an area of " << largestRectangle.Area() << "." << std::endl;   return 0; } rectangle.cc file  #include "rectangle.h" unsigned int Rectangle::Area() const {   // ===================== YOUR CODE HERE ========================   // Compute the area of this rectangle object.   // Remember that member functions can access the member variables of the   // class. Hint: look at `rectangle.h` to see the member variables you can   // access.   // =============================================================   unsigned int area = length_ * width_;   return area; } unsigned int Rectangle::Perimeter() const {   // ===================== YOUR CODE HERE ========================   // Compute the perimeter of this rectangle object.   // =============================================================   unsigned int perimeter = 2 * (length_ + width_);   return perimeter; } Rectangle LargestRectangleByArea(Rectangle &r1, Rectangle &r2) {   // ===================== YOUR CODE HERE ========================   // Compare the areas of the two given rectangles, and return   // the Rectangle whose area is larger.   // =============================================================   Rectangle result = r1.Area() > r2.Area() ? r1 : r2;   return result; } rectangle.h file  class Rectangle {  public:   // Setter functions of the Rectangle class.   void SetLength(unsigned int length) {     length_ = length;   }   void SetWidth(unsigned int width) {     width_ = width;   }   // Getter functions of the Rectangle class.   unsigned int GetLength() const {     return length_;   }   unsigned int GetWidth() const {     return width_;   }   // Other member functions of the Rectangle class.   unsigned int Area() const;   unsigned int Perimeter() const;  private:   // Member variables of the Rectangle class.   unsigned int length_;   unsigned int width_; }; Rectangle LargestRectangleByArea(Rectangle &r1, Rectangle &r2);

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter8: Data And Network Communication Technology
Section: Chapter Questions
Problem 41VE
icon
Related questions
Question
100%

I have this program that runs perfetly but receives a stylecheck error and I have no idea how to fix the error. I will attach the style check error below and the sample outputs.

main.cc file

#include <iostream>

#include "rectangle.h"

int main() {
  unsigned int length = 0;
  unsigned int width = 0;
  Rectangle r1; 
  Rectangle r2;
  std::cout << "====== Rectangle 1 ======" << std::endl;
  // ===================== YOUR CODE HERE ========================
  // Accept user input for the length and width of rectangle 1,
  // and instantiate a new Rectangle object with these inputs.
  // =============================================================
  std::cout << "Please enter the length: "; // input length
  std::cin>>length;
  r1.SetLength(length);
  std::cout << "Please enter the width: "; // input width
  std::cin>>width;
  r1.SetWidth(width);
  std::cout << "Rectangle 1 created with length " << r1.GetLength() << " and width " <<  r1.GetWidth() << std::endl;
  std::cout << "The area of rectangle 1 is: " << r1.Area() << std::endl;
  std::cout << "The perimeter of Rectangle 1 is: " << r1.Perimeter() << std::endl << std::endl; 

  std::cout << "====== Rectangle 2 ======" << std::endl;
  // ===================== YOUR CODE HERE ========================
  // Accept user input for the length and width of rectangle 2,
  // and instantiate a new Rectangle object with these inputs.
  // =============================================================
  std::cout << "Please enter the length: ";
  std::cin>>length;
  r2.SetLength(length);
  std::cout << "Please enter the width: ";
  std::cin>>width;
  r2.SetWidth(width);
  std::cout << "Rectangle 2 created with length " << r2.GetLength() << " and width " << r2.GetWidth() << std::endl;
  std::cout << "The area of rectangle 2 is: " << r2.Area() << std::endl; 
  std::cout << "The perimeter of Rectangle 2 is: " << r2.Perimeter() << std::endl << std::endl;
  // ===================== YOUR CODE HERE ========================
  // Call LargestRectangleByArea to determine which rectangle
  // is larger, and print out its length, width, and area.
  // Follow the README for formatting.
  // =============================================================
  Rectangle largestRectangle = LargestRectangleByArea(r1, r2);
  std::cout << "The largest rectangle has a length of " << largestRectangle.GetLength() << ", a width of "
   << largestRectangle.GetWidth() << ", and an area of " << largestRectangle.Area() << "." << std::endl;
  return 0;
}

rectangle.cc file 

#include "rectangle.h"

unsigned int Rectangle::Area() const {
  // ===================== YOUR CODE HERE ========================
  // Compute the area of this rectangle object.
  // Remember that member functions can access the member variables of the
  // class. Hint: look at `rectangle.h` to see the member variables you can
  // access.
  // =============================================================
  unsigned int area = length_ * width_;
  return area;
}

unsigned int Rectangle::Perimeter() const {
  // ===================== YOUR CODE HERE ========================
  // Compute the perimeter of this rectangle object.
  // =============================================================
  unsigned int perimeter = 2 * (length_ + width_);
  return perimeter;
}

Rectangle LargestRectangleByArea(Rectangle &r1, Rectangle &r2) {
  // ===================== YOUR CODE HERE ========================
  // Compare the areas of the two given rectangles, and return
  // the Rectangle whose area is larger.
  // =============================================================
  Rectangle result = r1.Area() > r2.Area() ? r1 : r2;
  return result;
}

rectangle.h file 

class Rectangle {
 public:
  // Setter functions of the Rectangle class.
  void SetLength(unsigned int length) {
    length_ = length;
  }
  void SetWidth(unsigned int width) {
    width_ = width;
  }

  // Getter functions of the Rectangle class.
  unsigned int GetLength() const {
    return length_;
  }
  unsigned int GetWidth() const {
    return width_;
  }

  // Other member functions of the Rectangle class.
  unsigned int Area() const;
  unsigned int Perimeter() const;

 private:
  // Member variables of the Rectangle class.
  unsigned int length_;
  unsigned int width_;
};

Rectangle LargestRectangleByArea(Rectangle &r1, Rectangle &r2);

35890 warnings generated.
/home/runner/lab04-danielhdz2000/prob02/main.cc:16:3: warning: uninitialized record typ
e: 'r1' [cppcoreguidelines-pro-type-member-init, hicpp-member-init]
Rectangle r1;
{}
/home/runner/lab04-danielhdz2000/prob02/main.cc:17:3: warning: uninitialized record typ
e: 'r2¹ [cppcoreguidelines-pro-type-member-init, hicpp-member-init]
Rectangle r2;
{}
/home/runner/Lab04-danielhdz2000/prob02/main.cc:52:13:
variable largestRectangle' [readability-identifier-naming]
Rectangle largestRectangle = LargestRectangleByArea(r1, r2);
NN
largest rectangle
NN
Style checker failed
warning: invalid case style for
Transcribed Image Text:35890 warnings generated. /home/runner/lab04-danielhdz2000/prob02/main.cc:16:3: warning: uninitialized record typ e: 'r1' [cppcoreguidelines-pro-type-member-init, hicpp-member-init] Rectangle r1; {} /home/runner/lab04-danielhdz2000/prob02/main.cc:17:3: warning: uninitialized record typ e: 'r2¹ [cppcoreguidelines-pro-type-member-init, hicpp-member-init] Rectangle r2; {} /home/runner/Lab04-danielhdz2000/prob02/main.cc:52:13: variable largestRectangle' [readability-identifier-naming] Rectangle largestRectangle = LargestRectangleByArea(r1, r2); NN largest rectangle NN Style checker failed warning: invalid case style for
Sample Output:
====== Rectangle 1 ======
Please enter the length: 2
Please enter the width: 3
Rectangle 1 created with length 2 and width 3
The area of Rectangle 1 is: 6
The perimeter of Rectangle 1 is: 10
====== Rectangle 2 ======
Please enter the length: 4
Please enter the width: 5
Rectangle 2 created with length 4 and width 5
The area of Rectangle 2 is: 20
The perimeter of Rectangle 2 is: 18
The largest rectangle has a length of 4, a width of 5, and an area of 20.
Transcribed Image Text:Sample Output: ====== Rectangle 1 ====== Please enter the length: 2 Please enter the width: 3 Rectangle 1 created with length 2 and width 3 The area of Rectangle 1 is: 6 The perimeter of Rectangle 1 is: 10 ====== Rectangle 2 ====== Please enter the length: 4 Please enter the width: 5 Rectangle 2 created with length 4 and width 5 The area of Rectangle 2 is: 20 The perimeter of Rectangle 2 is: 18 The largest rectangle has a length of 4, a width of 5, and an area of 20.
Expert Solution
Step 1

The solution is given below for the above given question:

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ListBox
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning