2016-08-23 5 views
1

こんにちは私は基本的なプログラムを修正するための助けが必要です。 SurfaceAreaと私のLateralAreaにエラーが発生しています。エラーは以下の通りである....オブジェクトタイプ「INT」と呼ばいくつかの修正が必要ですSurfaceAreaとLateralArea

はバイナリ表現(「ダブル」と「ダブル」)

の関数または関数ポインタ

無効オペランドありません

私のコードは、あなたが乗算演算子を省略することはできませんので、2(bottombase + topbase)が間違っている下記....

#include <iostream> 
using namespace std; //allows me to use cout and cin w/o typing std in the main 

int main(int argc, const char * argv[]) 
{ 
    double height;  //initialzing my variables 
    double bottombase; 
    double topbase; 

    double volume; 
    double LateralArea; 
    double SurfaceArea; 


    cout << "Please type in the height: ";   //asking users for information in order to find volume, and surface area 
    cin >> height; 

    cout << "Please type in the length of one side of the bottom base: "; 
    cin >> bottombase; 

    cout << "Please type in the length of one side of the top base: "; 
    cin >> topbase; 

    volume = height * bottombase * topbase; 

    cout << "Your volume is: " << volume << endl; 

    LateralArea = 2(bottombase + topbase) * sqrt(((bottombase-topbase)/2)^2 + height^2); 

    SurfaceArea = LateralArea1 + bottombase^2 + topbase^2; 

    cout << "Your surface area is: " << SurfaceArea << endl; 

    return 0; 
} 
+0

'2(ボトムベース+トップベース)'は '2 *(ボトムベース+トップベース)'でなければなりません。 '^'はビットごとに排他的です。代わりに 'pow'を使うか、それだけで数値を乗算してください –

答えて

3

で、2 * (bottombase + topbase)する必要があります。また、^演算子は、あなたが思うとは思わない。 C++では、ビット単位のXORであり、あなたが気にしていたことではない可能性が最も高いです。 C++には動力演算子がないので、例えばxと言ったら、x * xを明示的に行うか、powのように関数を使ってください:pow(x, 2)powを使用するには、#include <cmath>が必要です。

関連する問題