here there, im trying to insert a menu into my program, it only need to be a simple one so that the user can select which stage of the program they would like, here is copy of the program, could anyone give me advice/help. cheers.
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
cout << "The distance between point " << i << " and " << i+1 << "is: " << L[i] << endl;
}
if ( i = ns )
{
L[i] = sqrt( (x[i]-(x[1]))*(x[i]-(x[1])) + (y[i]-(y[1]))*(y[i]-(y[1])) );
cout << "The distance between point " << i << " and " << 1 << "is: " << L[i] << endl;
cout << endl;
}
}
// calculation of perimeter
void designer :: calc_perimeter ()
{
peri = 0;
for ( i=1; i<=ns-1; i++ )
{
peri = peri + L[i];
}
if ( i = ns)
peri = peri + (sqrt (((x[i] - x[1])*(x[i] - x[1])) + ((y[i] - y[1])*(y[i] - y[1]))));
cout << "The perimeter of the shape is " << peri << endl;
cout << endl;
}
// calculation of area
void designer :: calc_area ()
{
area = 0;
for ( i=1; i<=ns - 1; i++ )
{
area = area + (0.5*(x[i]*y[i+1]-x[i+1]*y[i]));
}
if ( i = ns )
{
area = area + (0.5*(x[i]*y[1]-x[1]*y[i]));
}
cout << "The area of the shape is " << area << endl;
cout << endl;
}
You should start by displaying the menu, reading input, then performing an action based on the input. It's likely you would want to put it in a loop of some kind as well.