#include <iostream>
#include <cmath>
using namespace std;
//prototypes for all separate functions
int chooseFunc(int);
int chooseMethod(int);
int numRect(int, int);
int numTrap(int, int);
int startPoint(int);
int endPoint(int);
int rectAlg(int, int, double, double, int, double, double, int, int, int, int, int, int);
int func1(int, int, int);
int func2(int, int, int);
int func3(int, int, int);
int func4(int, int, int);
int func5(int, int, int);
int funcSum(int, double, double, int, int, int, int, int, int);
//calls all the functions
int main(){
int choose, choose2, start, end, which, rect, trap, answer1, answer2, answer3, answer4, answer5, x, n;
choose = chooseFunc(choose);
choose2 = chooseMethod(choose2);
rect = numRect(rect, choose2);
trap = numTrap(trap, choose2);
start = startPoint(start);
end = endPoint(end);
n = rectAlg(choose, start, end, rect, n);
return 0;
}
//asks user which function they want to use
int chooseFunc(int choose){
cout<<"Choose a function (1,2,3,4, or 5): "<<endl;
cin>>choose;
return choose;
}
//asks the user which method they want to use
int chooseMethod(int choose2){
cout<<"Would you like to calculate the area using the rectangle, trapezoid, or both? (1,2, or 3): "<<endl;
cin>>choose2;
return choose2;
}
//asks for the number of rectangles
int numRect(int rect, int choose2){
if((choose2 == 1)  (choose2 == 3)){
cout<<"How many rectangles would you like? "<<endl;
cin>>rect;
return rect;
}
}
//asks for the number of trapezoids
int numTrap(int trap, int choose2){
if((choose2 == 2)  (choose2 == 3))
cout<<"How many trapezoids would you like? "<<endl;
cin>>trap;
return trap;
}
//asks the user for the starting point
int startPoint(int start){
cout<<"Please select a starting point, a = "<<endl;
cin>>start;
return start;
}
//asks the user for the ending point
int endPoint(int end){
cout<<"Please select an ending point, b = "<<endl;
cin>>end;
return end;
}
int func1(int x, int choose, int answer1){
if(choose == 1){
answer1 = (2*(pow(x,5)))+ pow(x,3)10*x+2;}
return answer1;
}
int func2(int answer2, int x, int choose){
if(choose == 2){
answer2 = (6*(pow(x,2)))x+10;}
return answer2;
}
int func3(int answer3, int x, int choose){
if(choose == 3){
answer3 = (5*x + 3);}
return answer3;
}
int func4(int answer4, int x, int choose){
if(choose == 4){
answer4 = (2*(pow(x,3)))+120;}
return answer4;
}
int func5(int answer5, int x, int choose){
if(choose == 5){
answer5 = (2*pow(x,2));}
return answer5;
}
int funcSum(int choose, double sum , double n, int x, int answer1, int answer2, int answer3, int answer4, int answer5 ){
sum = 0;
cin >> choose;
if (choose == 1)
sum += func1(n);
else if (choose == 2)
sum += func2(n);
else if (choose == 3)
sum += func3(n);
else if (choose == 4)
sum += func4(n);
else if (choose == 5)
sum += func5(n);
}
int rectAlg(int choose, int choose2, double start, double end, int rect, double n, double sum, int x, int answer1, int answer2, int answer3, int answer4, int answer5){
if (choose2 == 1  choose2 == 3){
double increment = (end  start)/rect;
double area = 0;
double total_area = 0;
for (int i = 1; i <= rect; i++)
{
area = i*increment * funcSum(n);
total_area += area;
}
cout << "The total area of all the rectangles for the function is: " << total_area <<endl;}
}
