2011-04-09 2 views
-3

잘못된 일을 이해하지 못합니다. 스피 초보자 및 캔트 그림 밖으로 trimtype은 정의이며, '비닐 내부의 준비는'문제는 가능성이 줄 수있는 constant.please 도움정의되지 않은 문자 및 상수가 많은 문자

#include "stdafx.h" 
#include <iostream> 
#include <string> 
#include <iomanip> 
#include <cctype> 

using namespace std; 

    void getIntroduction(); 
    void getBasePrice(double& BaseCost); 
    void getEngineCost(double& EngineCost, string& EngineType); 
    void getTrimCost(double& TrimCost, string& TrimType); 
    void getRadioCost(double& RadioCost, string& RadioType); 
    void calcTotalCost(double& BaseCost, double& EngineCost, double& TrimCost, double& RadioCost, double& ShippingCost, double& DealerCost); 

int _tmain(int argc, _TCHAR* argv[]) 
{ 
    double ShippingCostOut; 
    double DealerCostOut; 
    double BaseCostOut; 
    double EngineCostOut; 
    double TrimCostOut; 
    double RadioCostOut; 
    double TotalCostOut; 
    string EngineTypeOut; 
    string TrimTypeOut; 
    string RadioTypeOut; 
    string ExitKey; 

    ShippingCostOut = 500.00; 
    DealerCostOut = 175.00; 

    cout << endl; 
    cout << endl; 
    getIntroduction(); 
    cout <<endl; 
    cout <<endl; 
    cout << " Your selections will determine final Price" << endl; 
    cout << endl; 
    getBasePrice(BaseCostOut); 
    cout<< endl; 
    getEngineCost(EngineCostOut,EngineTypeOut); 
    cout<< endl; 
    getTrimCost(TrimCostOut,TrimTypeOut); 
    cout<< endl; 
    getRadioCost(RadioCostOut,RadioTypeOut); 
    cout<< endl; 
    cout << endl; 
    TotalCostOut = ShippingCostOut + DealerCostOut + BaseCostOut + EngineCostOut + TrimCostOut + RadioCostOut; 
    system("CLS"); 
    cout << " Your selections result in:" << endl; 
    cout << " Base Cost - $" << BaseCostOut << endl; 
    cout << endl; 
    cout << " " << EngineTypeOut << " - $" << EngineCostOut << endl; 
    cout << endl; 
    cout << " " << TrimTypeOut << " - $" << TrimCostOut << endl; 
    cout << endl; 
    cout << " " << RadioTypeOut << " - $" << RadioCostOut << endl; 
    cout << endl; 
    cout << " Shipping Cost - $" << ShippingCostOut << endl; 
    cout << " Dealer Cost - $" << DealerCostOut << endl; 
    cout << endl; 
    cout << " The total cost of the vehicle is: $" << TotalCostOut << endl; 
    cout << endl; 
    cout << "Enter any key and hit Enter to end program." << endl; 
    cin >> ExitKey; 

    return 0; 

} 

void getIntroduction() 
    { 
     cout << "Universal Motors New Car Price Calculator" << endl; 
     cout << " You will select your Options" << endl; 
     cout << endl; 
     cout << " The shipping cost - $500.00"<<endl; 
     cout << " The dealer cost - $175.00"<<endl; 
     cout<< endl; 


    } 

void getBasePrice(double& BaseCost) 
    { 

      char BaseCheck; 
      BaseCheck = 'A'; 
      cin.clear(); 
      cin.sync(); 


      do 
      { 
       BaseCheck = 'A'; 
       cout << endl; 
       cout << " Please enter the base price for the new car: " << endl; 
       cout << " Please enter Base Price in this format xxxxx.xx (x is a number):" <<endl; 
       cout << endl; 
       cout << "$ "; 
       cin >> BaseCost; 
       cout << BaseCost * 2; 


      } while (BaseCheck == 'S'); 

    } 

    void getEngineCost(double& EngineCost, string& EngineType) 
    { 
     char EngineLetter; 
     do 
     { 
      cout << endl; 
      cout << " Please choose your engine type: "<< endl; 
      cout<< endl; 
      cout << " S - 6 cylinder engine - $150.00"<<endl; 
      cout << " E - 8 cylinder engine - $475.00"<<endl; 
      cout << " D - Diesel engine  - $750.00"<<endl; 
      cout << endl; 
      cout << " Please enter your engine type: "; 
      cin >> EngineLetter; 


      switch (EngineLetter) 
      { 

       case 'S': 
        EngineCost = 150.00; 
        EngineType = "6 cylinder engine"; 
       break; 

       case 'E': 
        EngineCost = 475.00; 
        EngineType = "8 cylinder engine"; 
       break; 

       case 'D': 
        EngineCost= 750.00; 
        EngineType = "Diesel engine"; 
       break; 

    } 

void getTrimCost(double& TrimCost, string& TrimType); 
    { 
     char TrimChoice; 
     do 
     { 
      cout << endl; 
      cout << "Please choose your Trim Type:" << endl; 
      cout<< endl; 
      cout << " V - Vinyl interior trim - $50.00"<<endl; 
      cout << " C - Cloth interior trim - $225.00"<<endl; 
      cout << " L - Leather interior trim - $800.00"<<endl; 
      cout << endl; 
      cout << " Please enter your Trim: "; 
      cin >> TrimChoice; 

      switch (TrimChoice) 
      { 
       case 'V': 
        double TrimCost = 50.00; 
        TrimType = 'Vinyl interior trim'; 
       break; 

       case 'C': 
        TrimCost = 225.00; 
        TrimType = "Cloth interior trim"; 
       break; 

      case 'L': 
       TrimCost= 800.00; 
       TrimType = "Leather interior trim"; 
      break; 

    } 

void getRadioCost(double& RadioCost, string& RadioType); 
    { 
     char RadioChoice; 
     do 
     { 

      cout << endl; 
      cout << "Please choose your Radio:" << endl; 
      cout<< endl; 
      cout << " C - AM/FM Radio - $100.00" << endl; 
      cout << " P - CD/DVD  - $400.00" << endl; 
      cout << endl; 
      cout << " Enter Selection Please: "; 
      cin >> RadioChoice; 


      if (RadioChoice == 'C') 
      { 
       double RadioCost = 100.00; 
       RadioType = "AM/FM Radio"; 
      } 

      else 
       if (RadioChoice == 'P') 
       { 
        double RadioCost = 400.00; 
        RadioType = "CD/DVD"; 
       } 
     } 
+0

-1. 나는 당신의 코드에서 어떤 trimtype도 보지 못했다. – Nawaz

+0

환영합니다. 다음 번에는 정확한 문제와 그 문제가 발생한 곳과 같은 추가 정보를 제공해주십시오. 일반적으로 설명 된 문제와 관련이없는 정보는 제외하십시오. – julkiewicz

답변

5

로 너무 많은 문자가 이유 :

TrimType = 'Vinyl interior trim'; 

에서에게 C 및 C++의 작은 따옴표 (')는 char 리터럴 즉 단일 문자를 지정합니다. 하지만 당신의 TrimType 그것이 string의하는 char 아니다, 그래서 당신은 큰 따옴표 (") 사용해야합니다 : 정확한 컴파일러 오류를 게시하지 않는

TrimType = "Vinyl interior trim"; 
+0

안녕하세요 고마워하지만 지금은이 메시지 오류 범용 모터 calc.cpp (167) : 오류 C2065 : 'TrimType': 신고되지 않은 식별자 도와주세요! – los

+0

원래 문제와 관련이 없으므로 별도의 질문으로 게시해야합니다. 문제를 재현하는 작은 스 니펫 코드 만 있으면됩니다. –