121218 Eighth Chapter Exercise 6.cpp: Defines the entry point for a console application.
* * Copyright (c) 2012, Computer College of Yantai University * All rights reserved. * Author: Liu Tongbin * Date of Completion: December 18, 2012 * Version number: v1.0 * Input Description: * Problem Description: Need to find three cuboid volume, please write an object-based program 。
Data including Length,width,height, requires the use of member functions to achieve the following functions 1, by the keyboard input 3 cuboid long, wide, high 2, calculate the volume of the cuboid 3, Output 3 cuboid volume * Program output: * Problem analysis: slightly
* Algorithm design: Slightly * * * #include "stdafx.h" #include <iostream> using namespace std;
Declares class Area {public:void Set_area ();
void Show_area ();
Private:double length;
Double width;
Double height;
Double area1;
};
Enter the function void Area::set_area () {cout<< "Enter the cuboid width and height separately:" <<endl;
cin>>length>>width>>height;
}//Calculation function void Area::show_area () {area1=length*width*height;
cout<< "cuboid area is:" <<area1<<endl;
}//main function int main () {area area2,area3,area4;//definition object Area3.set_area ();//Function call Area3.show_area ();
Area3.set_area ();//Function call Area3.show_area (); Area3.set_area ();//function tuningWith Area3.show_area ();
return 0;
}