You are on page 1of 16

Area & Volume Calculator Description

The main objective of this assignment is to design a program that can


calculate the area and the volume of certain particular shape.
The selected shape that the program should consist of is as below:
In mathematics the area of a plane figure refers to the number of square
units the figure covers. The area is the inside shape or space measured in
square units.

No
1.

Area
Rectangle

Formula
Area = Length x Width

2.

Square

Area = Length x Length

3.

Triangle

Area = x Base x Height

4.

Circle

Area = x Radius

Volume is measured in "cubic" units.


No
1.

Formula
Volume = Length x Width x Height

2.

Volume
Rectangular
Solid
Cube

3.

Cones

Volume = 1/3 x x Radius x Height

4.

Sphere

Volume = 4/3 x x Radius

5.

Cylinder

Volume = x Radius x Height

Volume = Lenght

Black Book Design for Area


N
o
1.

Shape

Black Book

Rectangle
L
Rec_Area = L
W

2.

C-Programing Code

B.B
Area

Rec_Area

Square
B.B

Sq_Area = L L

3.

Sq_Area

Triangle
B
Tri_Area = B
H

4.

AREA

B.B
AREA

Tri_Area

Circle
B.B

Cir_Area = r

AREA

Cir_Area

Int Rec_Area (Int L , Int


W)
{
Int Area ;
Area= L * W ;
Return Area ;
}

Int Sq_Area (Int L)


{
Int Area ;
Area= L * L ;
Return Area ;
}

Int Tri_Area (Int B , Int H)


{
Int Area ;
Area= 0.5 * B * H ;
Return Area ;
}

Int Cir_Area (Int r)


{
Int Area ;
Area= 3.142 * r * r ;
Return Area ;
}
2

Black Book Design for Volume


N
o
1.

Shape

Black Book

Rectangle Solid
L
Rec_Area = L
W

2.

C-Programing Code

B.B
Vol

Rec_Vol

Cube
B.B

Cb_vol = L L
L

3.

Vol

Cb_Vol

Cone
B.B

r
Con_Vol =
H

Vol

Con_Vol

1/3 r H

4.

Sphere
B.B

Sp_Vol = 4/3
r

Vol

Sp_Vol

Int Rec_Area (Int L , Int


W)
{
Int Vol ;
Vol= L * W ;
Return Vol ;
}

Int Cb_vol (Int L)


{
Int Vol ;
Vol= L * L * L ;
Return Vol ;
}

Int Con_Vol (Int r , Int H)


{
Int Vol ;
Vol= 0.33 *3.14 * r * r
*H;
Return Vol ;
}

Int Sp_Vol (Int r)


{
Int Vol ;
Vol=1.33 * 3.14 * r * r
*r ;
3

Return Vol ;
}
5.
Cylinder
Cy_Vol = r
H

r
H

B.B
Vol

Cy_Vol

Int Cy_Vol (Int r, Int H)


{
Int Vol ;
Vol = 3.14 * r * r *H ;
Return Vol ;
}

Flow Chart of the Program


Start Program

Select Area or
Volume Calculator

Shape Selection

Area

Volume

Rectangle,
Square, Triangle,
Circle

Rectangle Solid,
Cube Cone,
Sphere, Cylinder

Read data:
,r , H, L, B

Calculate Area
or volume

Print Area or
Print volume

Start program again or

C- Programming Codes
Terminate Program

A program to calculate the volume or area of geometry shapes

#include <stdio.h>
int main ()
{
int choice11;
int choice22;
int terminate = 1;

while( terminate == 1)
{
printf("Please enter\n 1 for volume\n 2 for area\n User choice : ");
scanf("%d", & choice11);

if( choice11 == 1)
{

printf("\n\nPlease select the shape of volume: Enter: \n1 Rectangular Solid; \n2 - Cube; \n3 - Cone; \n4 - Sphere; \n5- Cylinder; :
\n\n");
scanf("%d",&choice22);

if (choice22== 4)
{
printf("\nShape selected: Sphere");

printf("\nEnter the radius:");


float r;
scanf("%f",&r);
float vol=(4.0*3.14*r*r*r)/ 3.0;

printf("\nThe Volume of Sphere: %f\n\n", vol);


}
else if(choice22== 1)
{
printf("\nShape selected: Rectangular solid");

printf("\nEnter the Length:");


float l;
scanf("%f",&l);

printf("\nEnter the Width:");


float w;
6

scanf("%f",&w);

printf("\nEnter the Height:");


float h;
scanf("%f",&h);
float vol = l*w*h;

printf("\nThe volume of Rectangular solid: %f\n\n", vol);


}
else if(choice22== 2)
{
printf("\nShape selected: Cube ");
printf("\nEnter the side Length: ");
float l;
scanf("%f",&l);
float vol = l*l*l;
printf("\nThe Volume of Cube: %f\n\n", vol);
}
else if(choice22== 3)
{
printf("\nShape selected: Cone");
printf("\nEnter the Radius: ");
float r;
scanf("%f", &r);
printf("\nEnter the Height: ");
7

float h;
scanf("%f", &h);
float vol = (1.0*3.14*r*r*h)/ 3.0;
printf("\nThe Volume of Cone: %f\n\n", vol);
}
else if(choice22== 5)
{
printf("\nShape selected: Cylinder");
printf("\nEnter the Radius:");
float r;
scanf("%f",&r);
printf("\nEnter the Height:");
float h;
scanf("%f",&h);
float vol = 3.142*r*r*h;
printf("\nthe volume of Cylinder: %f\n\n", vol);
}

}
if (choice11 == 2)
{
printf("\n\nPlease select the shape of Area: Enter \n6 Rectangle; \n7 - Square ; \n8 - Triangle; \n9 - Circle : \n\n");
scanf("%d",&choice22);

if (choice22== 9)
{
printf("\nShape selected: Circle ");
printf("\nEnter the radius:");
float r;
scanf("%f",&r);
float Area = 3.14*r*r;
printf("\nThe Area of Circle: %f\n\n", Area);
}
else if(choice22== 6)
{
printf("\nShape selected: Rectangle ");
printf("\nEnter the Length:");
float l;
scanf("%f",&l);
printf("\nEnter the Width:");
float w;
scanf("%f",&w);
float Area = l*w;
printf("\nThe Area of Rectangle: %f\n\n", Area);
}
else if(choice22== 7)
{
printf("\nShape selected: Square");
printf("\nEnter the side Length: ");
9

float l;
scanf("%f",&l);
float Area = l*l;
printf("\nThe Area of Square: %f\n\n", Area);
}
else if(choice22== 8)
{
printf("\nShape selected: Triangle");
printf("\nEnter the Base: ");
float b;
scanf("%f", &b);
printf("\nEnter the Height: ");
float h;
scanf("%f", &h);
float Area = (1*b*h)/2;
printf("\nThe Area of Triangle: %f\n\n", Area);
}
}

printf("Enter 1 to run the program or 2 to terminate: \n");


scanf("%d",&terminate);
}
return 0;
}
10

Calculation Test (AREA)


Rectangle Area

Area = Length x Width

Square Area

Area = Length x Length

11

Triangle

Area = x Base x Height

Circle

Area = x radius

12

Calculation Test (VOLUME)


Rectangular solid

Vol = Length x Width x Height

13

Cube

Vol = Length

Cones

Vol = 1/3 x x radius x Height

Sphere

Vol = 4/3 x x radius

14

Cylinder

Vol = x radius x Height

Run Program again or terminate

15

16

You might also like