Hello All,
It's my first time on the forum but I hope to become a valued member in the future. The reason for my post is that I enrolled in my first C++ programming class this semester and I am having a bit of trouble. I have emailed my professor for help and even attempted to find a tutor but no one has the time it seems. Since it is my first class I am a "novice" in every since of the word so I apologize if I am any trouble.
The assignment he gave the class is as follows:
(Related to arrays)
Write a function that will calculate the circumference of a polygon.
(I'm assuming that the distance formula will be used here ..length of segment blah..blah)
Write another function that will calculate the area of a polygon.
(which is y sub 0 * delta x + 1/2 * delta x * delta y)
or at least he said that was the formula for concave as well as convex*shrugs
we must allow for up to 20 coordinates.
This is what I have so far:
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::setw;
int arrayx[20]; //array's containing x,y coordinates
int arrayy[20]; //array's containing x,y coordinates
float polycirc; // hold value "circumference of polygon"
float polyarea; // hold value "area of polygon"
int option = 0;
int main()
{
//testing values cout << polycirc << polyarea << option << endl;
cout << "1. Enter the polygon\n" << endl;
cout << "2. Calculate the circumference of the polygon\n" << endl;
cout << "3. Calculate the area of the polygon\n" << endl;
cout << "4. Exit\n" << endl;
while ((option = cin.get()) != 0 )
switch (option)
{ //start switch
case '1':
cout << "Enter a polygon\n";
break;
case '2':
cout << "Calculate the circumference of the polygon\n";
break;
case '3':
cout << "Calculate the area of the polygon\n";
break;
case '4':
cout << "Good Bye!\n";
return 0;
break;
case ' ':
break;
case '\n':
break;
case '\t':
break;
default:
cout << "Please enter another option\n";
break;
} //end switch
return 0;
}
Any help would be greatly appreciated ... the assigment is due wednesday the 19th.
Thanks a bunch
Chris
It's my first time on the forum but I hope to become a valued member in the future. The reason for my post is that I enrolled in my first C++ programming class this semester and I am having a bit of trouble. I have emailed my professor for help and even attempted to find a tutor but no one has the time it seems. Since it is my first class I am a "novice" in every since of the word so I apologize if I am any trouble.
The assignment he gave the class is as follows:
(Related to arrays)
Write a function that will calculate the circumference of a polygon.
(I'm assuming that the distance formula will be used here ..length of segment blah..blah)
Write another function that will calculate the area of a polygon.
(which is y sub 0 * delta x + 1/2 * delta x * delta y)
or at least he said that was the formula for concave as well as convex*shrugs
we must allow for up to 20 coordinates.
This is what I have so far:
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cout;
using std::cin;
using std::endl;
using std::setw;
int arrayx[20]; //array's containing x,y coordinates
int arrayy[20]; //array's containing x,y coordinates
float polycirc; // hold value "circumference of polygon"
float polyarea; // hold value "area of polygon"
int option = 0;
int main()
{
//testing values cout << polycirc << polyarea << option << endl;
cout << "1. Enter the polygon\n" << endl;
cout << "2. Calculate the circumference of the polygon\n" << endl;
cout << "3. Calculate the area of the polygon\n" << endl;
cout << "4. Exit\n" << endl;
while ((option = cin.get()) != 0 )
switch (option)
{ //start switch
case '1':
cout << "Enter a polygon\n";
break;
case '2':
cout << "Calculate the circumference of the polygon\n";
break;
case '3':
cout << "Calculate the area of the polygon\n";
break;
case '4':
cout << "Good Bye!\n";
return 0;
break;
case ' ':
break;
case '\n':
break;
case '\t':
break;
default:
cout << "Please enter another option\n";
break;
} //end switch
return 0;
}
Any help would be greatly appreciated ... the assigment is due wednesday the 19th.
Thanks a bunch
Chris