我正在编写一个“自动售货机”程序,我需要有 5 个项目,其中 3 个项目的成本是整数,另外 2 个项目的成本是小数。
我只if在此代码中使用语句,但我的cost变量有错误。
我做错了什么?
代码如下:
#include <iostream>
using namespace std;
int main() {
cout << "Vending Machine" << endl;
cout << "----Items------" << endl;
cout << "1. Popcorn: $2" << endl;
cout << "2. Coconut Clusters: $3" << endl;
cout << "3. Granola Bar: $2.50" << endl;
cout << "4. Trail Mix: $1.50" << endl;
cout << "5. Chocolate: $1" << endl;
cout << "Enter you selection: " << flush;
int …Run Code Online (Sandbox Code Playgroud)