dfsfsdf

sfsfsdf
Last edited on
I really don't know how to figure out the cos.
You made complex mathematical computations to determine volume and surface area, but cannot do a primitive caplulation to determine cost using amount and price?

cost ($) = volume (m3) × price ($/m3)
Please, do not delete your messages.

Original message:
leetgb wrote:
Write a C++ program that asks the user to input the upper and base side lengths and the
height (in meters). The calculate and output, using the values, equations, and format
below, the following values:
• Volume of the truncated square pyramidal mold: 1
3
(a
2 + ab + b
2
)h
• Surface area: of the mold: a
2 + b
2 + 2(a + b)
q
(
a−b
2
)
2 + h
2
• Cost of concrete to fill mold (per m3
): $120
• Cost of labor to build (per m3
): $85
• Total cost of job
Here is an example. In your input and output, follow this input and output format exactly
(i.e. same input and output messages, whitespace, two digits to the right of the decimal
place, etc.). Remember that the number formatting commands are given in the (9th edition
of the) textbook on page 56.
Input the top side length (in m): .5
Input the base side length (in m): 1
Input the height (in m): 1
Volume of the mold (in cubic meters): 0.58
Surface area of the mold (in square meters): 4.34
Cost of concrete for mold: $70.00
Cost of labor: $49.58
Total cost: $119.58


#include <cmath>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
double cost_concrete = 120;
double cost_labor = 85;
double total_cost;
double a, b, h;
double v, s;
// b = top side length, a = base side length


cout << "Input the top side length (in m): ";
cin >> b;

cout << "Input the base side length (in m): ";
cin >> a;

cout << "Input the height (in m): ";
cin >> h;

v = (1/3 * (pow(a,2) + (a*b) + pow(b,2))) * h;
s = pow(a,2) + pow(b,2) + ((2*(a+b)) * (sqrt(pow(((a-b)/2),2)) + pow(h,2)));

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout << "Volume of the mold (in cubic meters): " << v << endl;

cout << "Surface area of the mold (in square meters): " << s << endl;

cout << "Cost of concrete for mold: " << "$" << cost_concrete << endl;

cout << "Cost of labor: " << "$" << cost_labor << endl;

cout << "Total cost: " << "$" << total_cost << endl;


return 0;
}


This is my code, and I really don't know how to figure out the cos.
Do i need to use here if , do , while or string?
Topic archived. No new replies allowed.