-4

したがって、基本的に、ユーザーの選択に応じてさまざまな入力と出力をユーザーに要求するプログラムを作成しようとしています。cin と同様に switch メソッドを使用してこれを行っています。何らかの理由で、コンパイルできません。ここで私が間違っていることについて、誰かが洞察を提供できますか? ありがとう!

   #include <iostream>
          using namespace std;
     int main()
     {
     cout << "Welcome to my countertop store.\n" << "Before running this program you will need        the depth and 
     length of the block, which edges are to be finished and 
     the style, as well as the grade to be used 
     and the finish.\n";

     cout << "Please enter the depth of the counter: ";
     cin << counterDEPTH;
     cout << "Please enter the length of the counter: ";
     cin << counterLENGTH;
     cout << "Number of long edges to be finished: ";
     cin << longEDGES;
     cout << "Number of short edges to be finished: ";
     cin << shortEDGES;
     cout << "Please choose a grade: \n";
     switch (grade)
       {
    case Marble:
        double cost = 92.99;
    case Granite:
        double cost = 78.99;
    case Quartz:
        double cost = 56.99;
    case Quartite:
        double cost = 39.99;
}
     cout << "Selected grade: " & grade;
     cout << "Would you like it polished (y/n)? ";
     switch (polished)
       {
              case Yes:
    double newcost = cost;
    double newcost = (.15 * newcost);
              case No:
    double newcost = 0.00;
    }
     cout << "Cost Information\n";
     cout << "Stone Cost: " & cost;
     cout << "Polishing Cost: " & newcost;
     cout << "Edge Cost: " & (longEdges * shortEdges * 4.99);
     cout << "Total: " & cost+newcost+(longEdges * shortEdges * 4.99); 
     return 0;
     }
4

5 に答える 5

1

まず、ほとんどすべての変数を宣言する必要があります。C と C++ はどちらも変数を使用する前に変数を宣言する必要があるため、これまでに使用したほとんどすべてのステートメントは違法です。

あなたのプログラムをちらりと見るだけで、それを壊す可能性のある他の多くの問題があるように見えます. この時点で、コンパイラの出力を使用して自分でデバッグしようとすると、はるかに便利になります。これまでに発見したすべてのエラーは、どのコンパイラでも発見されたはずだからです。

それでも問題が解決しない場合は、できればコンパイラからの出力\エラー メッセージとともに、より具体的な質問をする必要があります。

于 2012-09-23T19:27:29.977 に答える
0
cin << counterDEPTH;

に変更します

cin >> counterDEPTH;

他の人も同様に変更します

于 2012-09-23T19:24:03.200 に答える
0

cincoutwithの両方を書きました<<cinを使用する必要があります>>

于 2012-09-23T19:24:42.817 に答える
0

これはあなたのコードのすべてですか?ユーザー入力を保存する変数を宣言する必要があります。また、Yes/No/Marble/Granite/Quartz/Quartite もどこにも定義されていません。

#include <iostream>
using namespace std;
int main()
{
cout << "Welcome to my countertop store.\n" << "Before running this program you will need        the depth and 
length of the block, which edges are to be finished and 
the style, as well as the grade to be used 
and the finish.\n";

double counterDEPTH, counterLENGTH, longEDGES, shortEDGES;

cout << "Please enter the depth of the counter: ";
cin >> counterDEPTH;

switch ステートメントにも休憩が必要です。

case Marble:
    double cost = 92.99;
    break;
case Granite:
    double cost = 78.99;
    break;
于 2012-09-23T19:26:35.780 に答える
0
  1. cinステートメントを変更して>>、例えば

    cin >> counterDEPTH;

  2. ステートメントbreak;の各caseブロックの最後に追加します。switch

于 2012-09-23T19:28:44.070 に答える