Had an assignment in my programming course to make a console program that calculates the volume of a timber.
This was for the purpose of learning about functions, so I thought I'd share my completion of the assignment.

All this thanks to Bucky's very much helpful C++ tutorials. :)

Working on a translator atm. too, might post it here later on.






The code:

Main.cpp


#include <iostream>
#include "VolCalc.h"
using namespace std;

double pi = 3.14159265359;

int main()
{

   VolCalc aNObj;

   float a;
   float b;
   float c;

       cout << "State base diameter in meters:" << endl;
       cin >> a;
       cout << "State top diameter in meters:" << endl;
       cin >> b;
       cout << "State length in meters:" << endl;
       cin >> c;
       cout << "The volume of the timber is: " <<aNObj.addNumbers(a, b, c) <<" cubic meter(s).
";

}


VolCalc.h

#ifndef VOLCALC_H
#define VOLCALC_H


class VolCalc
{
   public:
       VolCalc();
       double pi = 3.14159265359;
       double addNumbers(float bd, float td, float length);

   protected:
   private:
};

#endif // VOLCALC_H


VolCalc.cpp

#include <iostream>
#include "VolCalc.h"

using namespace std;

VolCalc::VolCalc()
{
}

double VolCalc::addNumbers(float bd, float td, float length){
       double volym = (((bd/2)* (bd/2)+ (td/2) * (td/2) + (bd/2*td/2))/3*pi*length); //the algorithm for the actual calculation
       return volym;

   }