如何在C++;名为Flix for Fun的程序利润报告? 我在C++中为C++的一个介绍类编写了一个程序,但是程序中有多个错误,但是我似乎无法弄明白如何把所有的bug都排除出来。

如何在C++;名为Flix for Fun的程序利润报告? 我在C++中为C++的一个介绍类编写了一个程序,但是程序中有多个错误,但是我似乎无法弄明白如何把所有的bug都排除出来。,c++,debugging,C++,Debugging,该程序应该要求用户提供电影名称、成人和儿童票的销售数量,并计算总票房利润、净票房利润和支付给发行商的金额 我似乎不知道如何初始化变量adultTicketPrice和 childTicketPrice,我想我声明了它们,并试图弄清楚如果我已经声明了它们,它们是否需要初始化 儿童票的价格怎么会超出范围 为什么我会遇到其他错误?我该如何修复它们 // Michael VanZant // Flix for Fun Profit Report #include <iostream> #i

该程序应该要求用户提供电影名称、成人和儿童票的销售数量,并计算总票房利润、净票房利润和支付给发行商的金额

我似乎不知道如何初始化变量adultTicketPrice和 childTicketPrice,我想我声明了它们,并试图弄清楚如果我已经声明了它们,它们是否需要初始化

儿童票的价格怎么会超出范围

为什么我会遇到其他错误?我该如何修复它们

// Michael VanZant
// Flix for Fun Profit Report

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
    // Create all double variables
    double adultTicketsSold, childTicketsSold, grossBoxProfit, netBoxProfit, 
    amtPaidDist, adultTicketPrice, childTicketPrice

    adultTicketPrice = 12;
    childTicketPrice = 7;

    cout << fixed << setprecision(2);

    // Create the string variable
    string movieName;

    // Get the name of the movie and store it in the movieName string
    cout << "What is the name of the movie?";
    getline(cin, movieName);
    cout << "\n";

    // Cin.ignore to ignore the string variable type
    cin.ignore();

    // Get the amount of adult and child tickets sold
    cout << "How many adult tickets do you want to buy?";
    cin >> adultTicketsSold;
    cout << "\n";
    cout >> "How many child tickets did you want to buy?";
    cin >> childTicketsSold;
    cout << "\n";

    // Calculate the amount of gross box office profit and display it
    grossBoxProfit = (childTicketsSold * childTicketPrice) + (adultTicketsSold * adultTicketPrice);
    cout << "Gross Box Office Profit: $" << grossBoxProfit;
    cout << "\n";

    // Calculate the net box profit amount and display it
    netBoxProfit = grossBoxProfit * .20;
    cout << "Net Box Profit Amount: $" << netBoxProfit;
    cout << "\n";

    // Calculate the amount paid to distributor and display it
    amtPaidDist = grossBoxProfit - netBoxProfit;
    cout << "Amount Paid to Distributor is: $" << amtPaidDist;

    return 0;
}
//Michael VanZant
//Flix for Fund利润报告
#包括
#包括
#包括
使用名称空间std;
int main()
{
//创建所有双变量
双倍成人票已售出、儿童票已售出、grossBoxProfit、netBoxProfit、,
amtPaidDist,成人票,儿童票
成人票券价格=12;
childTicketPrice=7;
不能出售儿童票;
cout当编译器说“expected initialiser”时,它与以下行无关:

adultTicketPrice = 12;
childTicketPrice = 7;
这实际上是赋值,而不是初始化(尽管一些旧的C术语将第一个赋值称为初始化)

不,这是因为它认为您仍然在这条线上,提供声明和(可选)初始值设定项:

double adultTicketsSold, childTicketsSold, grossBoxProfit, netBoxProfit, 
amtPaidDist, adultTicketPrice, childTicketPrice
那是因为你没有在它的末尾放一个

此外:


您的意思是
声明!=已初始化。您发布的代码中还缺少一些
字符。当您在帖子中完全没有错误消息时,所有其他错误都不是问题描述。我确实看到了代码中的;错误,感谢您为我指出这一点。当您说没有错误消息时“我的帖子中有ges,这意味着我需要把它们放在我帖子的正文中吗?@SeanV:否则我们必须猜测它们是什么。我不知道你为什么要把它们留给自己?幸运的是,正如你从下面看到的,我已经变得相当善于猜测。我不明白你为什么使用
cin.ignore();
(上面的评论也没有多大意义)。这意味着我必须在门票数量之前添加一个随机输入。否则,效果会很好!顺便问一下,请让你的教授帮我停止教人们使用浮点数来表示货币,好吗?你建议我改用什么?@SeanV:关于货币,你应该继续学习你教授的课程内容ial,但我真希望他们不要这样教它。货币应该是定点的;它可以解决无数的问题,而且不需要任何成本(lol)。整数便士通常就足够了;否则就是十分之一便士。@SeanV:关于
cin.ignore()
,我不知道,我只是把它取下来。你得想想为什么要把它放在那里——从我的观点来看,我们又回到了猜测这个问题上。
cout >> "How many child tickets did you want to buy?";