-4
我正在製作一個關於訂購漢堡和蘇打水的有趣程序。我做了一切都沒有測試,它不能正常工作。程序運行不正常
代碼:
#include <iostream>
using namespace std;
int orderDrinks();
int orderBurgers();
int main()
{
orderBurgers();
orderDrinks();
return 0;
}
int orderBurgers()
{
bool(orderBurgersLoop);
while (orderBurgersLoop = true)
{
cout << "How many burgers would you like to order?" << endl;
int burgersAmount;
cin >> burgersAmount;
bool(burgersAmountLoop);
while (burgersAmountLoop = true)
{
if (burgersAmount > 1)
cout << "You ordered " << burgersAmount << " burgers. We will notice you when they are done." << endl;
else if (burgersAmount = 1)
cout << "You ordered " << burgersAmount << " burger. We will notice you when it's done!" << endl;
else if (burgersAmount <= 0)
cout << "Are you sure?" << endl;
char orderBurgersLeaveOrStay;
cin >> orderBurgersLeaveOrStay;
bool(orderBurgersLeaveOrStayLoop);
while (orderBurgersLeaveOrStayLoop = true)
{
if (orderBurgersLeaveOrStay = 'Yes')
orderBurgersLoop = false;
if (orderBurgersLeaveOrStay = 'No')
{
orderBurgersLeaveOrStayLoop = false;
burgersAmountLoop = false;
orderBurgersLoop = false;
}
}
}
}
return 0;
}
int orderDrinks()
{
cout << "Would you like to order anything to drink?" << endl;
char orderDrinksOption;
cin >> orderDrinksOption;
bool(orderDrinksLoop);
while (orderDrinksLoop = true)
{
if (orderDrinksOption = 'Yes')
{
cout << "How many drinks would you like to order?" << endl;
int drinksAmount;
cin >> drinksAmount;
if (drinksAmount = 1)
cout << "You ordered " << drinksAmount << " drinks. We will notice you when they are done!" << endl;
else if (drinksAmount > 1)
cout << "You ordered " << drinksAmount << " drink. We will notice you when it's done!" << endl;
}
if (orderDrinksOption = 'No')
orderDrinksLoop = false;
else
cout << "Yes or No?";
}
return 0;
}
在第一個問題,如果我鍵入0它打印回「你下令1個漢堡,布拉布拉」,它就像我想它不工作。我在做什麼(寫作)是錯誤的?
「它就像我想它不工作」 - 這並沒有真正告訴我們很多。什麼具體是/不工作,在它之外輸出1? – user2366842
歡迎來到StackOverflow。請使用更具描述性的標題。請在問題中描述您的問題,而不僅僅是「不按要求工作」。什麼是「想要的」,它究竟在做什麼,以什麼方式做出不同?你試過什麼了? –
「我做了一切都沒有測試」,儘可能好。請逐步檢查您的邏輯,然後再次發佈,我們不是在這裏做你的hw –