任何人都可以請幫我理解爲什麼這個程序繼續給我錯誤?我目前正在使用Visual C++ 2008 Express,錯誤發生後只是錯誤。我找不到任何明顯的東西,但請看看。C++的基本東西。什麼不見了???不能那麼明顯
# include "stdafx.h"
# include <iostream>
# include <string>
# include <iomanip>
using namespace std;
int main()
{
string name;
int age, amountBeer, amountRootBeer;
double beer, rootBeer, taxRate, sum, total, cashTendered, change, tax;
name=「」;
age=amountBeer=amountRootBeer=0;
sum=total=cashTendered=change=tax=0.0;
beer=5.99;
rootBeer=3.99;
taxRate=.07;
cout << 「Welcome to BeerMart; where all your beer needs are met. \n\n」
<< 「Please enter your name: 「;
getline (cin, name);
cout << 「Hello << name << 「.\n」
<< 「Please enter your age: 「;
cin >> age;
if (age > 21)
{
cout << 「Enter the amount of beers to purchase: 「;
cin >> amountBeer;
cout << 「Enter the amount of root beers to purchase: 「;
cin >> amountRootBeer;
else
cout << 「Enter the amount of root beers you want to purchase;
cin >> amountRootBeer;
}
cout << 「Please wait while we process your order.」;
sum = (amountBeer * beer) + (amountRootBeer * rootBeer);
tax = sum * taxRate;
total = sum + tax;
system (「pause.exe」);
if (amountBeer > 0 && amountRootBeer > 0)
{
cout << 「You ordered 「 << amountBeer << 「 beer(s) and 「 << amountRootBeer<< 「 rootBeers.\n\n」
<< 「Beer cost $」 << beer << 「, and root beers cost $」 << rootBeer << 「.」 << 「Your sum is: $「<< sum << 「\n」
<< 「Your tax is: $」 << tax << 「\n」
<< 「And your total altogether is; $」<< total << endl;
}
if (amountBeer == 0 && amountRootBeer > 0)
{
cout << 「You ordered 「 << amountRootBeer<< 「 rootBeer(s).\n\n」
<< 「Your sum is: $「<< sum << 「\n」
<< 「Your tax is: $」 << tax << 「\n」
<< 「And your total is; $」<< total << endl;
}
if (amountBeer > 0 && amountRootBeer == 0)
{
cout << 「You ordered 「 << amountBeer << 「 beer(s)\n\n」
<< 「Your sum is: $「<< sum << 「\n」
<< 「Your tax is: $」 << tax << 「\n」
<< 「And your total is; $」<< total << endl;
}
cout << 「Please enter the amount of cash tendered: $」;
cin >> cashTendered;
change = cashTendered - total;
cout << 「Your change is; $」 << change<< 「.\n\n」
<< 「Have a great day!」;
return 0;
}
這裏是錯誤...
1>------ Build started: Project: CH5HW Simple Beer sales, Configuration: Debug Win32 ------
1>Compiling...
1>CH5HW Simple Beer sales.cpp
1>c:\users\james\documents\visual studio 2008\projects\ch5hw simple beer sales\ch5hw simple beer sales\ch5hw simple beer sales.cpp(16) : error C2065: 'ìî' : undeclared identifier
和這樣的例子不勝枚舉。
你沒有張貼任何錯誤,這是一件壞事,但只要看一下語法在您的文章突出。 – chris
你寫了哪個編輯器?或從一些在線文檔複製? – P0W
「代碼給我錯誤」,沒有關於錯誤的信息是沒有意義的。 「錯誤」就在你面前,絕對沒有理由不把它們提供給我們。如果這個問題對你來說不夠重要,無法寫出它並提供詳細信息,那麼我們當然不應該足夠重要,試圖找出問題的癥結所在。如果您需要我們的幫助,請[edit]並提供**關於錯誤的實際信息**。 –