I am so lost on what to do so please help how ever you can.

I must write a program to calculate the cost and time it takes to fill a swimming pool.


* Inputs: 
Length, Width, and Depth of the pool (This is a gross simplification, since pools are not really rectangular cubes.)
Fill rate of the pool in Gallons per minute
* Calculation functions:
  * Write a function to calculate the total cubic feet (Length x Width x Depth) and return the cubic feet.
Inputs: Length, Width, and Depth Return cubic feet
  * Write a function to calculate the number of gallons:
1 cubic foot = 7.48051948 US gallons (Create a constant to hold the conversion factor.)
Input: Cubic Feet Return Gallons
  * Write a function to calculate the cost to fill the pool as follows:
Calculate 1000’s of gallons by dividing the total gallons by 1000 and putting the result in an 
integer variable.
Use the following table to generate the cost:
Input: Gallons Return Cost
* Call your functions from main()
* Outputs: 
    * Total cubic feet
    * Total gallons
    * Costm
    * Time to fill in minutes
Aoption: (The best grade is a 100%) Note: No B option on this one
* Combine the functions to calculate the cubic feet and number of gallon.  
    * Inputs to the function: Length, Width, Depth
    * Outputs (via reference variables): Cubic Feet, Gallons
Example Prototype:
void PoolSize(float Length, float Width, float Depth, float &CubicFeet, float &Gallons);
* Write a function that calculate the time to fill as follows: 
    * Inputs to the function: Gallons
    * Outputs (via reference variables): Hours and Minutes
Example Prototype:
void FillTime(float Gallons, float FillRate, ,float &Hours, float &Minutes);

Dani AI

Generated

Short, practical plan: implement small, well-named functions for (1) volume in cubic feet, (2) gallons conversion, (3) cost-from-gallons (use the assignment’s tier table), and (4) fill-time (minutes → hours/minutes). Validate inputs (non‑negative, consistent units — convert inches to feet first if needed) and test each function independently, as suggested. The original post from doesn’t include the cost table, so the example below uses a placeholder tiered pattern that should be replaced by the exact table from the assignment.

#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <climits>

constexpr double CF_TO_GALLONS = 7.48051948; // use the assignment's conversion

double calcVolume(double L, double W, double D) { return L * W * D; }
double cubicFeetToGallons(double cf) { return cf * CF_TO_GALLONS; }

double computeCost(double gallons) {
    int thousands = static_cast<int>(gallons / 1000.0); // truncates; assignment requests integer
    struct Tier { int upTo; double pricePerThousand; };
    std::vector<Tier> tiers = { {5, 3.50}, {10, 3.00}, {20, 2.50}, {INT_MAX, 2.00} }; // placeholders
    double cost = 0.0;
    int prev = 0, remain = thousands;
    for (auto &t : tiers) {
        int span = std::min(remain, t.upTo - prev);
        if (span > 0) cost += span * t.pricePerThousand;
        prev = t.upTo;
        remain -= span;
        if (remain <= 0) break;
    }
    return cost;
}

void computeFillTime(double gallons, double fillRateGpm, int &hours, int &minutes) {
    if (fillRateGpm <= 0) { hours = minutes = 0; return; }
    double totalMinutes = gallons / fillRateGpm;
    int totalMin = static_cast<int>(std::round(totalMinutes));
    hours = totalMin / 60;
    minutes = totalMin % 60;
}

Testing and gotchas: use known values to verify (e.g., a 20×10×5 ft pool yields 1000 cu ft → ~7480.52 gallons with the conversion). Be explicit about integer behavior: static_cast<int>(gallons/1000.0) truncates; if billing rounds up by partial thousands, use std::ceil(gallons/1000.0). Prefer double/constexpr for precision, and format output with std::fixed + std::setprecision. Incremental testing of each function (volume → gallons → cost → time) makes debugging straightforward, exactly as advised.

I am so lost on what to do so please help how ever you can.
I must write a program to calculate the cost and time it takes to fill a swimming pool.

Take each step and program it. Start with:

  • Inputs:
    Length, Width, and Depth of the pool

Write this sections, test it. When it works, move on to

Calculation functions:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.