C++ C++;程序不读取公式

C++ C++;程序不读取公式,c++,math,loops,numbers,C++,Math,Loops,Numbers,我一直在编写的程序应该输出以下内容: *所需油漆的加仑数 *所需的劳动时间 *油漆的价格 *劳务费 *油漆工作的总成本 但是,它在每个字段中显示0。。我现在做错了什么? 非常感谢您的帮助。 这是我的密码: //Headers #include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <iomanip> using namesp

我一直在编写的程序应该输出以下内容: *所需油漆的加仑数 *所需的劳动时间 *油漆的价格 *劳务费 *油漆工作的总成本 但是,它在每个字段中显示0。。我现在做错了什么? 非常感谢您的帮助。

这是我的密码:

//Headers
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <iomanip>

using namespace std;

void PaintJobEstimator(double gallonprice, double calc)
{
    float numBucket=0;
    float hours=0;
    float bucketCost=0;
    float laborCharges=0;
    float totalCost=0;
    //calculates number of buckets of paint (gallons) needed
    numBucket=numBucket+calc*(1/115);
    //calculates paint cost
    bucketCost=bucketCost+gallonprice*numBucket;
    //calculates labor hour
    hours=hours+calc*(8/115);
    //calculates labor charges
    laborCharges=hours*18;
    //calculates total cost
    totalCost=totalCost+bucketCost+laborCharges;
    //Console output
    cout << "The number of Gallons of paint required:\t" << setprecision(2) << numBucket << endl;
    cout << "The hours of labor required:\t" << setprecision(2) << hours << " hrs" << endl;
    cout << "The labor charges:\t$" << setprecision(2) << laborCharges << endl;
    cout << "The cost of the paint:\t$" << setprecision(2) << bucketCost << endl;
    cout << "The total cost of the paint job:\t$" << setprecision(2) << totalCost << endl;
}

void main ()
{
    int rooms;
    double calc=0;
    double wallspace;
    double gallonprice;
    cout << "=========================================================\n";
    cout << "___________________Paint Job Estimator___________________\n";
    cout << "_________________________________________________________\n";
    cout << endl;
    cout << "Enter the number of rooms: ";
    cin >> rooms;
    while (rooms<1) //validates rooms
    {
        cout << "Invalid entry, enter one or more rooms:\t";
        cin >> rooms;
    }
    for (int roomNum=1;
        roomNum<=rooms;
        roomNum++)
    {
        cout << "Enter the wall space in square meters for room " << roomNum << ":\t" << endl;
        cin >> wallspace;
        while (wallspace < 0.01)//validates wallspace
        {
            cout << "Invalid entry, please re-enter the wall area for room " << roomNum << ":\t";
            cin >> wallspace;
        }
        calc=calc+wallspace;
    }//end loop
    cout << "\nEnter price of the paint per gallon: ";
    cin >> gallonprice;
    if (gallonprice <10) //validates price per gallon
    {
        cout << "Invalid entry, Reenter price at a $10.00 minimum: ";
        cin >> gallonprice;
    }
    PaintJobEstimator(gallonprice,wallspace);
    system ("pause");
}
//标题
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
空隙率估算器(双加仑价格,双计算)
{
浮点数=0;
浮动小时=0;
浮扣成本=0;
浮动人工费=0;
浮动总成本=0;
//计算所需油漆桶数(加仑)
numBucket=numBucket+计算*(1/115);
//计算油漆成本
bucketCost=bucketCost+加仑价格*numBucket;
//计算工时
小时=小时+计算*(8/115);
//计算人工费用
人工费=小时*18;
//计算总成本
totalCost=totalCost+bucketCost+人工费;
//控制台输出

cout在某些计算中,您正在乘以零。例如,在以下代码行中:

numBucket=numBucket+calc*(1/115);
您将1/115放在括号中,由于整数除法,括号的计算结果为零。要达到预期效果,请尝试:

numBucket = calc / 115.0f;

paint.cc:34:12:错误:'::main'必须返回'int'