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:


#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).



#ifndef VOLCALC_H
#define VOLCALC_H

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


#endif // VOLCALC_H


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

using namespace std;


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;