2016-03-23 6 views
-1

私は一般的にC++とプログラミングの新人です。それは読んでいない、他に行くEDIT C++の例を解決して空の出力を得ようとしています

#include <iostream> 
#include <string> 
using namespace std; 
void main() 
{ 
    double x, y; 
    double cost; 
    char frt; 
    char Frcr; 
    char crow; 
    char R , r, F , f ; 
    int yes = 0, Yes = 0, No = 0, no = 0; 
    cout << "Please Enter length and Width of the picture in Inches :\n"; 
    cin >> x >> y; 
    cout << "Please Enter the Type of the Frame (R/F)(R Stands for Regular ,F Stands for Fancy) : \n"; 
    cin >> frt; 


    if ('frt' == 'r' || 'frt' == 'R') 
    { 
     cost = (x + y)*0.15; 
     cout << "Do you want to color the frame? (Yes/No) : \n"; 
     cin >> Frcr; 

     if ('frcr' == yes || 'frcr' == Yes) 
     { 
      cost = (x + y)*0.15; 
      cout << "The Cost is : " << (x + y)*0.15 + ((x + y)*0.10) << endl; 
     } 


     else if ('frcr' == no || 'frcr' == No) 
     { 
      cost = ((x + y)*0.15); 
      cout << "The Cost Is : " << cost << endl; 
     } 



    } 
    else 
     cout << "There is an Error " << endl; 
} 

場合、私は私はそれにそれを実行し、即座Rそれを置くしようとすると、このプログラムの最初の段階で、このプログラムを書くために The Program im trying to write.

をしようとしています:男の助けを借りての作業コード:)

#include <iostream> 

using namespace std; 
void main() 
{ 
    double x, z; 
    double cost; 
    char frt; 
    char Frcr; 
    int Crow; 
    int R, r, F, f; 
    int y, Y, N, n; 
    cout << "Please Enter The Width of the picture in Inches :"; 
    cin >> x; 
    cout << "Please Enter The length of the picture in Inches :"; 

    cin >> z; 
    cout << "Please Enter the Type of the Frame (R/F):" << endl; 
    cout << "(R Stands for Regular ,F Stands for Fancy) \n"; 
    cin >> frt; 



    if (frt == 'r' || frt == 'R') 
    { 
     cost = (x + z)*0.15; 




     cout << "Do you want to color the frame? (Y/N) : \n"; 
     cin >> Frcr; 
     if (Frcr == 'y' || Frcr == 'Y') 
     { 
      cout << "Type The Number Of The Crowns You Want ? :"; 
      cin >> Crow; 
      cout << "The cost With Frame Coloring : " << ((x + z)*0.15) + ((x + z)*0.10) + (Crow*0.35) << endl; 



     } 
     else if (Frcr == 'N' || Frcr == 'n') 
     { 
      cout << "Type The Number Of The Crowns You Want ? :"; 
      cin >> Crow; 
      cout << "The Cost is : " << ((x + z)*0.15) + (Crow*0.35) << endl; 

     } 
     else 
      cout << "Invalid Input." << endl; 


    } 
    else if (frt == 'f' || frt == 'F') 
    { 

     cout << "Do you want to color the frame? (Y/N) : \n"; 
     cin >> Frcr; 

     if (Frcr == 'y' || Frcr == 'Y') 
     { 
      cout << "Type The Number Of The Crowns You Want ? :"; 
      cin >> Crow; 
      cout << "The cost With Frame Coloring : " << ((x + z)*0.25) + ((x + z)*0.10) + (Crow*0.35) << endl; 



     } 
     else if (Frcr == 'N' || Frcr == 'n') 
     { 

      cout << "Type The Number Of The Crowns You Want ? :"; 
      cin >> Crow; 
      cout << "The Cost is : " << ((x + z)*0.25) + (Crow*0.35) << endl; 

     } 

     else 
      cout << "Invalid Input." << endl; 


    } 


    else 
     cout << "Invalid Input." << endl; 



} 
+0

と同じではありません場合は私に知らせてくださいこれは、if(「FRT」==「R」 '完全に間違っている|| ' frt == 'R') 'if(frt == 'r' || frt == 'R')'でなければなりません。すべて同じif文に適用されます – DimChtz

+0

ああありがとうございました:D – Bashar

+0

他にもいくつかの問題があります。あなたは、 'F'や' r'のような決して使用しない変数を宣言します。はい/いいえ答えを求めますが、行全体ではなく1文字だけを入力します。 – Barmar

答えて

1

この'frt' == 'r'は間違っています。 frt,fcrcrはどちらも変数です。 ''を削除します。それは次のようになります。

frt == 'r' 

この'frcr' == yesは、多くの理由で間違っています。 frcrも変数ですので、再度 ''を削除してください。それでもあなたが代わりにfrcr == "yes"を行うことはできません。

1)変更frcrstd::stringにまたは
を維持し、'y'または'Y'"yes"を変更します。

編集:あなたのコードは多くの点で間違っています。私はあなたが基本から始めることをお勧めします。あなたは学ぶ必要がある。

+0

これはC++ xDの最初の週です – Bashar

+0

基本を読み始めます。変数、データ型、基本的なC++構文など。 – DimChtz

0

最終的な作業コード。助けのために君たちをありがとうその作業罰金今:) は、それが画像

#include <iostream> 

using namespace std; 
void main() 
{ 
    double x, z; 
    double cost; 
    char frt; 
    char Frcr; 
    int Crow; 
    int R , r, F , f ; 
    int y , Y , N , n; 
    cout << "Please Enter The Width of the picture in Inches :"; 
    cin >> x; 
    cout << "Please Enter The length of the picture in Inches :"; 

    cin >> z; 
    cout << "Please Enter the Type of the Frame (R/F)(R Stands for Regular ,F Stands for Fancy) : \n"; 
    cin >> frt; 



    if (frt == 'r' || frt == 'R') 
    { 
     cost = (x + z)*0.15; 




     cout << "Do you want to color the frame? (Y/N) : \n"; 
     cin >> Frcr; 
     if (Frcr == 'y' || Frcr == 'Y') 
     { 
      cout << "Type The number of the crowns you want ? :"; 
      cin >> Crow; 
      cout << "The cost With Frame Coloring : " << ((x + z)*0.15) + ((x + z)*0.10)+(Crow*0.35) << endl; 



     } 
     else if (Frcr == 'N' || Frcr == 'n') 
     { 
      cout << "Type The number of the crowns you want ? :"; 
      cin >> Crow; 
      cout << "The Cost is : " << ((x + z)*0.15) + (Crow*0.35) << endl; 

     } 
     else 
      cout << "Invalid Input." << endl; 


    } 
    else if (frt == 'f' || frt == 'F') 
    { 

     cout << "Do you want to color the frame? (Y/N) : \n"; 
     cin >> Frcr; 

     if (Frcr == 'y' || Frcr == 'Y') 
     { 
      cout << "Type The number of the crowns you want ? :"; 
      cin >> Crow; 
      cout << "The cost With Frame Coloring : " << ((x + z)*0.25) + ((x + z)*0.10)+(Crow*0.35) << endl; 



     } 
     else if (Frcr == 'N' || Frcr == 'n') 
     { 

      cout << "Type The number of the crowns you want ? :"; 
      cin >> Crow; 
      cout << "The Cost is : " << ((x + z)*0.25) + (Crow*0.35) << endl; 

     } 

     else 
      cout << "Invalid Input." << endl; 


    } 


    else 
     cout << "Invalid Input." << endl; 



    } 
関連する問題