Finding cost of tile to cover W x H floor I am new to C++ and programming in general. After reading through my first book, I decided to take on some programming exercises and test what I learned. The exercise is phrased as follows: 


  Find Cost of Tile to Cover W x H Floor - Calculate the total cost of tile it would take to cover a floor plan of width and height, using a cost entered by the user.


This is the code I wrote for it: 

#include &lt;iostream&gt;

using namespace std;

int main() {

    double StartSquare, cost, width, height;    // Starting square meters and cost. Width and height of floor.

    cout &lt;&lt; "Enter value of 1 pack of tiles: ";
    cin &gt;&gt; cost;

    cout &lt;&lt; "Now enter the square metres covered by the pack: ";
    cin &gt;&gt; StartSquare;

    cout &lt;&lt; "What is the width of your room? ";
    cin &gt;&gt; width;
    cout &lt;&lt; "Now enter the height:\n";
    cin &gt;&gt; height;

    cout &lt;&lt; "You need to cover a total of " &lt;&lt; width * height &lt;&lt; " square metres.\n";
    cout &lt;&lt; "The total cost will be: " &lt;&lt; (width * height) * cost &lt;&lt; endl;

    return 0;
}


It does what I need it to, I just want to know whether it can be improved upon. This also brings me to question of: How do I self-review my own code? I don't want to have to constantly be asking a review of my code and rather self-assess it myself.
One of the most powerful techniques you will develop is called 'separation of concerns'. What this means when it boils down is that your program can be split into discrete logical units. Ideally one module (or in the case of c++, class) will do exactly one job without depending on any other.

This has a number of benefits in that the parts can be re-used without needing any knowledge of which parts of the program are using them.

here is your program again, split into essentially three sections, or concerns. Hopefully you will see that although there are more lines of code, the logic in the main() function is easier to follow. Also you can hopefully see that the "input_data" class is an entirely autonomous entity, which could be re-used to gather data for other parts of a bigger program:

I also fixed the small logic error in your calculation, which was easier to see when the calculations were separated from the input/output code.

#include &lt;iostream&gt;

using namespace std;

double area(double width, double height)
{
    return width * height;
}

double cost_to_cover(double area, double area_per_pack, double cost_per_pack)
{
    double packs_needed = area / area_per_pack;
    double cost = packs_needed * cost_per_pack;

    return cost;
}

struct input_data {
    double area_per_pack, cost_per_pack, width, height;    // Starting square meters and cost. Width and height of floor.

    void gather() {
        cout &lt;&lt; "Enter value of 1 pack of tiles: ";
        cin &gt;&gt; cost_per_pack;

        cout &lt;&lt; "Now enter the square metres covered by the pack: ";
        cin &gt;&gt; area_per_pack;

        cout &lt;&lt; "What is the width of your room? ";
        cin &gt;&gt; width;
        cout &lt;&lt; "Now enter the height:\n";
        cin &gt;&gt; height;
    }
};

int main() {

    // concern 1 - gather data
    input_data input;
    input.gather();

    // concern 2 - perform calculations
    double room_area = area(input.width, input.height);
    double cover_cost = cost_to_cover(room_area, input.area_per_pack, input.cost_per_pack);

    /// concern 3 - output the result
    cout &lt;&lt; "You need to cover a total of " &lt;&lt; room_area &lt;&lt; " square metres.\n";
    cout &lt;&lt; "The total cost will be: " &lt;&lt; cover_cost &lt;&lt; endl;

    return 0;
}