// lab02demo.cpp - demonstrates techniques for Lab02 // Calculates area of rectangle using length and // width entered by user; prints area, and then // prints either "larger" or "smaller" or "same" // as a fixed area equal to 1000. // cmc, updated 1/19/2018 #include using namespace std; int main() { // declare variables int length, width, area; // get data from user cout << "Enter length: " << endl; cin >> length; cout << "Enter width: " << endl; cin >> width; // calculate and print area result area = length * width; cout << "A " << length << " by " << width << " rectangle's area is " << area << "." << endl; // techniques above sufficient for coins.cpp problem // techniques below more than enough for meeting.cpp // print different message depending on area size int max = 1000; cout << "Maximum area is " << max << "." << endl; if (area > max) { int overuse = area - max; cout << "Your area is " << overuse << " more than that." << endl; } else if (area == max) cout << "Your area is exactly that." << endl; else { int leftover = max - area; cout << "Your area is " << leftover << " less than that." << endl; } return 0; }