problem with homework

the problem is i cant do it its verey hard i cant understand




area of Trapezoid= (b1+b2)*a\2



area of hexagon = 3*sqrt of 3 \2 * L^2


area of triangle = b*h\2





write three user defined functions : calculate_trapezoid , calcluate_Hexagon , and Calculate_Triangle to solve the equations.


using loops essential in this project




output should be like this :




b1---------b2-----------a-------------area of trapezoid


1.0--------1.0--------1.0------------1.00


1.5--------1.5--------1.5------------2.25


2.0--------2.0--------2.0------------4.00


2.5--------2.5--------2.5 ------------6.25


3.0--------3.0--------3.0------------9.00




L----------------------------area of hexagon



2 ------------------ 10.39

3 ----------------- 23.38

4 ----------------- 41.57

5 ----------------- 64.95

6 ----------------- 93.53






b ---------h----------area of triangle

3----------3----------4.50

6----------6----------18.00

9----------9----------40.50

12--------12-----------72.00

15--------15-----------112.50




its verey hard for me but i cant do it if someone could help please

and sorry for the long talking
Last edited on
:( -
Hi,

if not mind, i will advise you to use the selection statement, that is switch with case, here is the syntax;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int userchoice;
//receiving input
cout<<"Press 1 for trapezium, 2 for triangle, 3 for rectangle, 4 for all objects and press enter"<<endl;
cin>>userchoice<<endl
switch(userchoice)
{
case 1:
//codes for calculating the area of  trapezium
break;
case 2:
//codes for calculating the area of triangle
break;
case 3:
//codes for calculating the are of rectangle
break;
case 4:
//code for calculating the area of all objects
break;
default:
cout<<"You've selected an invalid object value"<<endl;  
break;
}


But let me no whether or not it works for you
IMO, I think the OP might have a legitimate right to complain here. Based on this line of the instructions:

write three user defined functions : calculate_trapezoid , calcluate_Hexagon , and Calculate_Triangle to solve the equations.


From what I read here he has to take input from the user to define the functions in his code. The only way I can think of to do that is to have a program prompt the user for input, dump the data to a .cpp file, then call an embedded compiler to link & build that new .cpp file to run the functions that the end user defined :D! That's all a bit much for a beginner!

EDIT: </sarcasm>
Last edited on
Topic archived. No new replies allowed.