Create a C++ Console project called Lab3a and add the following source document rect_struct.cpp to the project.
#include <iostream>
#include <iomanip>
using namespace std;
// This program uses a structure to hold data about a rectangle
// PLACE YOUR NAME HERE
// Fill in code to declare a structure named rectangle which has
// members length, width, area, and perimeter all of which are floats
int main()
{
// Fill in code to define a rectangle variable named box
cout << "Enter the length of a rectangle: ";
// Fill in code to read in the length member of box
cout << "Enter the width of a rectangle: ";
// Fill in code to read in the width member of box
cout << endl << endl;
// Fill in code to compute the area member of box
// Fill in code to compute the perimeter member of box
cout << fixed << showpoint << setprecision(2);
// Fill in code to output the area with an appropriate message
// Fill in code to output the perimeter with an appropriate message
return 0;
}
Exercise 1: Fill in the code as indicated by the comments “Fill in”.
(Paste your updated code and screen shot here.)
Exercise 2: Add code to the program above so
that the modified program will determine whether or not the
rectangle entered by the user is a square.
(Paste your updated code and screen shot here.)
Create a C++ Console project called Lab3a and add the following source document rect_struct.cpp to the...
Create a C++ project called lab3b and add the following source code init_struct.cpp to the project. #include <iostream> #include <string> #include <iomanip> using namespace std; // This program demonstrates partially initialized structure variables // PLACE YOUR NAME HERE struct taxPayer { string name; long socialSecNum; float taxRate; float income; float taxes; }; int main() { // Fill in code to initialize a structure variable named citizen1 so that // the first three members are initialized....
C++ program.
int main()
{
Rectangle box; // Define an
instance of the Rectangle class
double rectWidth; // Local variable for width
double rectLength; // Local variable for length
string rectColor;
// Get the rectangle's width and length from the
user.
cout << "This program will calculate the area of
a\n";
cout << "rectangle. What is the width? ";
cin >> rectWidth;
cout << "What is the length? ";
cin >>...
Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle objects and find their area and perimeter. Instructions Ensure the class file named Rectangle.cpp is open in your editor. In the Rectangle class, create two private attributes named length and width. Bothlength and width should be data type double. Write public set methods to set the values for lengthand width. Write public...
// This program uses the programmer-defined Rectangle class. #include "Rectangle.cpp" #include <iostream> using namespace std; int main() { Rectangle rectangle1; Rectangle rectangle2; rectangle1.setLength(10.0); rectangle1.setWidth(5.0); rectangle2.setLength(7.0); rectangle2.setWidth(3.0); cout << "Perimeter of rectangle1 is " << rectangle1.calculatePerimeter() << endl; cout << "Area of rectangle1 is " << rectangle1.calculateArea() << endl; cout << "Perimeter of rectangle2 is " << rectangle2.calculatePerimeter() << endl; cout << "Area of rectangle2 is " << rectangle2.calculateArea() << endl;...
Part 1 Fill in the code below as indicated by the comments in bold // PLACE YOUR NAME HERE // This program demonstrates how to use an array of structures #include <iostream> #include <iomanip> using namespace std; // Fill in code to declare a structure called taxpayer that has three // members: taxRate, income, and taxes – each of type float // ??? int main() { // Fill in code to define an array named citizen which holds 1/ 5...
The program must be in C# syntax. Write the definition for a generic class called Rectangle that has data members length and width. The class has the following member functions: setlength to set the length data member setwidth to set the width data member perimeter to calculate and return the perimeter of the rectangle area to calculate and return the area of the rectangle show to return a text to display the length and width of the rectangle sameArea that...
The program must be in C# syntax. Write the definition for a generic class called Rectangle that has data members length and width. The class has the following member functions: setlength to set the length data member setwidth to set the width data member perimeter to calculate and return the perimeter of the rectangle area to calculate and return the area of the rectangle show to return a text to display the length and width of the rectangle sameArea that...
The statement in the following program is in the incorrect order. Rearrange the statements so that they prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter, for a circle, it outputs the area and circumference; and for a cylinder, it output the volume and surface area. After rearranging the statements, your...
Hello I have a question. I would like to check if the code follows this requirement. Rectangle.h - A complete Rectangle Class including both declaration and definition appRectangle,cpp separate in two different files the class definition and implementation Code: rectangle.h // Rectangle class declaration. class Rectangle { private: double width; double length; public: void setWidth(double); void setLength(double); double getWidth() const; double getLength() const; double getArea() const; }; //************************************************** // setWidth assigns a value to the width member. * //************************************************** void...
I Need Help. I MUST USED VECTOR OF STRUCTUERS INSTEAD OF AN ARRAY. HOW CAN MAKE THIS INTO VECTOR STRUCTUERS? #include #include using namespace std; // This program demonstrates how to use an array of structures// PLACE YOUR NAME HERE // Fill in code to define a structure called taxPayer that has three// members: taxRate, income, and taxes -- each of type float int main(){ // Fill in code to declare an array named citizen which holds // 5 taxPayers structures cout...