Computer Programing Fundamental
Computer Programing Fundamental
char figure;
cin >> figure;
switch (figure) {
case 'd':
{
int choice;
float base, height, side1, side2, side3;
● TRAPEZOID (kenshin)
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'e': {
float calculateArea, base1, base2, height;
calculateArea = 0.5 * (base1 + base2) * height;
break;
}
● RHOMBUS ( sharmaine )
A=d1 x d2/2
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'R':
cout << "The area of the Rhombus is: " << area << endl;
break;
}
return 0;
A= base × height
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'R':
cout << "The area of the Rhombus is: " << area << endl;
break;
}
return 0;
A= side^2 × sin(A)
A= side^2 × sin(B)
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'R':
cout << "The area of the rhombus is: " << area << endl;
break;
}
return 0;
}
● PARALLELOGRAM ( Joseph )
- A = base x height
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'g': {
float Base, Height, area;
● POLYGON (Rowena)
#include <iostream>
#include <cmath>
using namespace std;
int main() {
char figure;
cin >> figure;
switch (figure) {
case 'h':
{
int numSides;
double sideLength, apothem;
cout << endl;
cout << "Please enter the Dimension needed." << endl;
cout << "For example: 123<space>inch" << endl;
cout << "Enter the length of one side of the polygon: ";
cin >> sideLength;
cout << "Area of the polygon: " << area << endl;
break;
}
}
● SPHERE (ghelbern)
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
case 'i':
{
float radius, radius_cube, volume ;
cout << endl;
cout << "Please enter the radius : " << endl;
cin >> radius_cube;
break;
}
}
return 0;
}
● CUBE (karl)
V = s³
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
case 'j':
{cout << endl;
cout << "Please enter the Dimension needed." << endl;
cout << "For example: 123<space>inch" << endl;
float side_length,volume;
cout << "Volume of the cube: " << volume << endl;
break;
}
}
return 0;
}
● PYRAMID (ericka)
TRIANGULAR- ⅓ (base area) (height)
RECTANGULAR- ⅓ (length) (width) (height)
HEXAGONAL- √3/2 (base²) (height)
SQUARE- ⅓ (base²) (height)
PENTAGONAL- ⅚ (apothem) (base) (height)
CODE
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
case 'k':
{
cout << endl;
cout << "Please enter the Dimension needed." << endl;
cout << "For example: 123<space>inch" << endl;
char shape;
float apothem, base, width, base_length, height, base_area, volume;
cout << "Volume of the Shape Base Pyramid is: " << volume << endl;
break;
}
}
return 0;
}
● PRISM (De Guia)
CODING:
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
case 'j':
{
if (shape == 'a') {
cout << "Enter the base edge and length " << endl;
cout << "Base edge: ";
cin >> base_edge;
cout << "length: ";
cin >> length;
volume = base_edge*base_edge*length;
} else if (shape == 'b') {
cout << "Enter base edge, height, and length: " << endl;
cout << "Base Edge: ";
cin >> base_edge;
cout << "Height: ";
cin >> height;
cout << "Length: ";
cin >> length;
volume = 0.5*base_edge*height*length;
} else if (shape == 'c') {
cout << "Enter the apothem,base edge and height " << endl ;
cout << "Apothem:";
cin >> apothem;
cout << "Base edge: ";
cin >> base_edge;
cout << "Height: ";
cin >> height;
volume = 3*apothem*base_edge*height;
} else if (shape == 'd') {
cout << "Enter the base edge and height " << endl;
cout << "Base edge: ";
cin >> base_edge;
cout << "Height: ";
cin >> height;
volume = 2*2.414213562*base_edge*height;
} else if (shape == 'e') {
cout << "Enter length, width and height " << endl;
cout << "Length: ";
cin >> length;
cout << "Width: ";
cin >> width;
cout << "Height: ";
cin >> height;
volume = length*width*height;
} else if (shape == 'f') {
cout << "Enter length, width and height " << endl;
cout << "Length: ";
cin >> length;
cout << "Width: ";
cin >> width;
cout << "Height: ";
cin >> height;
volume = 2.5*apothem*base_edge*height;
} else if (shape == 'g') {
cout << "Enter base edge, height" << endl;
cout << "Base edge: ";
cin >> base_edge;
cout << "height: ";
cin >> height;
volume = 1.75*base_edge*base_edge*2.07652*height;
} else {
cout << endl;
cout << "Error!" << endl;
cout << "Check your input and try again!"<< endl;
return 1;
}
cout << "Volume of the shape base prism is: " << volume << endl;
break;
}
}
return 0;
}
● CONE (junrex)
case 'l':
● CYLINDER ( karl )
V = π r²
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
case 'n':
{
cout << endl;
cout << "Please enter the Dimension needed." << endl;
cout << "For example: 123<space>inch" << endl;
float radius,height,volume;
if (radius==0 || height==0)
{
cout<<"invalid operation"<<endl;
}
if(radius!=0 && height!=0)
{
volume = (3.1416*radius*radius*height);
cout << "Volume of the cylinder: " << volume << endl;
break;
}
}
}
return 0;
}
GUIDE:
#include<iostream>
#include<cmath>
using namespace std;
int main ()
{
char figure;
cin >> figure;
switch (figure) {
break;
}
}
return 0;
}