I'm new to c++ this is my first assignment, so far I think I did good, i hope! But for my last code I'm suppose to show the results at 2 decimal points and the $ symbol. Please help!!! This is my code so far.
#include <iostream>
using namespace std;
int main()
{
const double PI = 3.14;
const double priceofSoil = 7.97;
const double priceOfGravel = 3.98;
// Display the header
cout << "Miguel Lopez" << endl << "Program 1 Greenhouse pot" << "\n";
cout << "Calculating the costs of soil and gravel for pots!" << "\n";
cout << "\n";
// Get diameter
float diameter;
cout << "Please enter the top diameter in inches: ";
cin >> diameter;
//How many pots to be calculated
float pots;
cout << "Please enter the number of pots: ";
cin >> pots;
// Calculate the bottom diameter
// Bottom diameter = top diameter - 2
float bottomDiameter;
bottomDiameter = diameter - 2;
// Calculate average diameter
// Average diameter = top diameter + bottom diameter / 2
float averageDiameter;
averageDiameter = (diameter + bottomDiameter)/2;
// Calculate average radius
// Average radius = averageDiameter/2
float averageRadius;
averageRadius = averageDiameter/2;
// Calculate volume of pots in cubic feet
// volume = PI * Radius * Radius * Height
float volume;
volume = (PI * averageRadius * averageRadius * height)*pots/1728;
cout << "Volume of pots in cubic feet is: " << volume << endl;
// Calculate volume of soil and gravel in pot
// 80% of volume is soil and gravel
float volumeOfGravelAndSoil;
volumeOfGravelAndSoil = 0.80 * volume;
// Volume of Gravel
// Volume of gravel = 1 inch of height * radius * radius * PI
float volumeOfGravel;
volumeOfGravel = (1 * PI * averageRadius * averageRadius)*pots/1728;
cout << "The volume of Gravel in cubic feet is: " << volumeOfGravel << endl;
// Cost of Gravel
// Cost of Gravel = priceOfGravel * volumeOfGravel
float costOfGravel = priceOfGravel * volumeOfGravel;
cout << "The cost of the gravel needed for the pots is: " << costOfGravel << endl;
//Volume of Soil
// Volume of soil = volumeOfGravelandSoil - volumeOfGravel
float volumeOfSoil;
volumeOfSoil = (volumeOfGravelAndSoil - volumeOfGravel);
cout << "The volume of Soil in cubic feet is: " << volumeOfSoil << endl;
//Cost of Soil
float costOfSoil;
costOfSoil = volumeOfSoil * priceofSoil;
cout << "The cost of the soil needed for the pots is: " << costOfSoil << endl;
cout << "\n";
//Total for gravel and soil
float totalOfGravelAndSoil;
totalOfGravelAndSoil = costOfSoil + costOfGravel;
cout << "The total cost for both soil and gravel is: " << totalOfGravelAndSoil << endl;