LAB 02A - PRISM VOLUME

A Prism Project

The program below computes the volume of a square prism. I mean it, just one, specific square prism. How lame! Let's modify this program and make it more versatile.

First, create an empty project and add a new source code, i.e., main.cpp, file; if you don't have down how to do this yet, follow directions in Lab 01. Call this project Lab02A and copy the code below into the main.cpp file within the project. Then update the comment section, and build/execute the program. Make sure everything runs fine before moving on to the next step.

Your Task

Your task is two-fold. First, change the program below to output the volume of the prism with an appropriate output statement. (Suggestion: do not start the next task until you are happy with the execution of this first task.) Second, change the program below to calculate the volume of any box-like structure or jail cell. (Oh, wait, I thought you said _prison_, not prism.) In other words, ask the user to enter a whole number for the length, width, and height of the prism (or prison), and then capture that input via appropriate input statements.

/* CSCI 261 Lab 02A: PRISM VOLUME
*
* Author: XXXX (_INSERT_YOUR_NAME_HERE_)
*
* Add more complete description here...
*/

// The include section adds extra definitions from the C++ standard library.
#include <iostream> // For cin, cout, etc.

// We will (most of the time) use the standard library namespace in our programs.
using namespace std;

// Must have a function named "main", which is the starting point of a C++ program.
int main() {

    /******** MODIFY OR INSERT CODE BELOW HERE ********/

    int length = 17;
    int width = 17;  
    int height = 2; 
    int volume;

    // Volume of a box is length times width times height. 
    volume = length * width * height;


    /******** MODIFY OR INSERT CODE ABOVE HERE ********/

  return 0; // signals the operating system that our program ended OK.
  
}
	

Lab Submission

You will submit your solution to this lab with your second homework assignment. Detailed instructions for doing this are posted in Homework 02.