Next week Items-2

Source: Internet
Author: User

Write an object-based program to find the volume of 3 long Fang (Bulk).
Data members include length (length), Width (width), height (heigth), volume, and require design member functions to implement the following functions:
(1) by the keyboard input 3 long Fang long, wide, high;
(2) Calculating the volume (volume) and surface area of the long Fang (areas);
(3) Output the volume and surface area of these 3 long Fang;
#include <iostream>
using namespace Std;
Class Bulk
{
Double L, W, H;
Public
void volume (double, double, double);
void areas (double, double, double);
};
void Bulk::volume (Double L, double W, double h)
{
cout << "Volume:" << l*w*h << Endl;
}
void Bulk::areas (Double L, double W, double h)
{
cout << "surface area:" << l*w * 2 + l*h * 2 + w*h * 2;
}
void Main ()
{
Bulk B1;
cout << "Enter the length, width and height of 3 cuboid respectively:" &LT;&LT;ENDL;
int i = 0;
Double b[9];
for (; I <= 8; ++i)
{
if (i%3==0)
cout << i/3+1 << ".";
CIN >> B[i];
}
for (int j = 0; J <=2; ++j)
{
cout << "cuboid" << j+1;
B1.areas (B[J * 3], B[j * 3 + 1], B[j * 3 + 2]);
B1.volume (B[J * 3], B[j * 3 + 1], B[j * 3 + 2]);
}
Cin >> I;
}

Next week Items-2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.