01. /* 02. * copyright and version Declaration of the program part 03. * Copyright (c) 2013, Yantai University Computer college student 04. * All rightsreserved. 05. * file name: bulk. cpp 06. * Author: Zhao guanzhe 07. * Completion Date: April 8, March 29, 2013. * version: v1.0 09. * input Description: 10. * Problem description: 11. */# include <iostream> using namespace std; class Bulk {public: Bulk (double a = 1.0, double B = 1.0, double c = 1.0): length (), width (B), height (c) {}double volune (void); double area (void); void get_value (); void showmessage (); private: double length, width, height ;}; int main () {Bulk B [5] = {Bulk (2.3, 4.5, 6.7), Bulk (1.5, 3.4), Bulk (10.5 )}; // output the volume and surface area of the five long square columns respectively below (int I = 0; I <4; I ++) {cout <"no." <I + 1; B [I]. showmessage ();} B [4]. get_value (); B [4]. showmessage () ;}void Bulk: get_value () {cout <"Enter the length, width, and height of the long column :"; cin> length> width> height;} double Bulk: volune (void) {return (length * width * height);} double Bulk: area (void) {return (2 * length * width + 2 * length * height + 2 * length * width);} void Bulk: showmessage () {cout <"the volume of the column is:" <volune () <"the surface area of the column is:" <area () <endl ;}
Running result: