Seeking cube volume, surface area (c ++)

// find cube volume, surface area (c ++)

#include <iostream>
#include <stdlib.h>
#define COST 20
using namespace std;

class tiji
{
private:
double length,width,height;
public:
tiji(){};
tiji(double l, double w, double h) //构造函数的形参,给私有变量赋值
{
length =l;
width =w;
height =h;
}
double changft_tiji()
{
//double v;
double v=length*width*height;
return v;
}
double biao_area()
{
double s;
s=2*(length*height+length*width+width*height);
return s;
}
double repaie()
{
double ss ;
ss = 2*(length*height+length*width+width*height)-length*width;
return ss;
}

void input (); // statement

};

void tiji::input()
{
cin>>length>>width>>height;
}

MENU void ()
{
COUT << "*********************************" << endl;
COUT << "1. volume seeking cube" << endl;
COUT << "2. seeking cube surface area" << endl;
COUT << "cube seeking the decor 3." << endl;
COUT << "of 0. the exit ! "<< endl;
cout <<" ********************************* "<< endl << endl ;
}
void _exit ()
{
COUT << "*********************************" << endl;
COUT << "Welcome to this program" << endl;
cout << "quit success" << endl;
cout << "Thank you!" << endl;
cout << "************ ************************************************************ "<< endl << endl;
}


main int ()
{
tiji B;
int C;
MENU ();
the while (. 1)
{
COUT << "Please enter the length, width and height values:";
B.input ();
COUT << "Select:" ;
CIN >> C;
Switch (C)
{
Case. 1:
COUT << "1. volume seeking cube" << B.changft_tiji () << endl;
BREAK;
Case 2:
COUT << "cube 2. seek surface area "<< B.biao_area () << endl;
BREAK;
Case. 3:
COUT <<" cube seeking the decor 3. "<< B.repaie () * the cOST << endl;
BREAK;
Case 0:
System ( "cls"); // clear screen
_exit ();
Exit (1);
BREAK;
default:
cout << "does not have this feature!";
}
}


//B.changft_tiji(3,4,5)
// << COUT "is cuboid volume:" << B.changft_tiji () << endl;
// << COUT "surface area of the cuboid is:" << B .biao_area () << endl;
// cout << "cuboid renovation cost is:" << B.repaie () * cOST << endl;
return 1; // 1 for true
}




Guess you like

Origin www.cnblogs.com/duanqibo/p/11110323.html