But all the cool people are in my tutorial group.
So it should be good.
Well, that's it.
Not much else...
but as promised, i will post the extremely long code.
Goodbye.
#include <iostream>
#include <math.h>
void squareArea()
{
float sqArea = 0;
std::cout << "Please type in the length of the squares side: ";
std::cin >> sqArea;
float ans = sqArea * sqArea;
std::cout << "The area of the sqaure is: " << ans << std::endl;
}
void triangleArea()
{
float triBase = 0;
float triHeight = 0;
std::cout << "Please type in the length of the traingles base: ";
std::cin >> triBase;
std::cout << "Please type in the length of the traingles hieght: ";
std::cin >> triHeight;
float ans = (triBase / 2) * triHeight;
std::cout << "The area of the triangleis: " << ans << std::endl;
}
void circleArea()
{
float pi = 3.141592654;
float ciRadius = 0;
std::cout << "Please type in the circles radius: ";
std::cin >> ciRadius;
float ans = pi * (ciRadius * ciRadius);
std::cout << "The area of the circle is: " << ans << std::endl;
}
void circleCircumference()
{
float pi = 3.141592654;
float ciRadius = 0;
std::cout << "Please type in the circles radius: ";
std::cin >> ciRadius;
float ans = 2 * pi * ciRadius;
std::cout << "The circumference of the circle is: " << ans << std::endl;
}
void cubeVolume()
{
float cubeSide = 0;
std::cout << "Please type in the length of the cubes side: ";
std::cin >> cubeSide;
float ans = cubeSide * cubeSide * cubeSide;
std::cout << "The volume of the cube is: " << ans << std::endl;
}
void cubeSurface()
{
float cubeSide = 0;
std::cout << "Please type in the length of the cubes side: ";
std::cin >> cubeSide;
float ans = 6 * (cubeSide * cubeSide);
std::cout << "The surface area of the cube is: " << ans << std::endl;
}
void trapSurfaceAndVolume()
{
float trapBase1 = 0;
float trapBase2 = 0;
float trapHeight = 0;
float trapSide1 = 0;
float trapSide2 = 0;
float trapLength = 0;
std::cout << "Please type in Base 1 of the trapezoid: ";
std::cin >> trapBase1;
std::cout << "Please type in Base 2 of the trapezoid: ";
std::cin >> trapBase2;
std::cout << "Please type in Side 1 of the trapezoid: ";
std::cin >> trapSide1;
std::cout << "Please type in Side 2 of the trapezoid: ";
std::cin >> trapSide2;
std::cout << "Please type in the height of the trapezoid: ";
std::cin >> trapHeight;
std::cout << "Please type in the Length of the trapezoid: ";
std::cin >> trapLength;
float trapVol = (trapBase1 + trapBase2 + trapSide1 + trapSide2) * trapLength;
float trapSurface = (trapBase1 + trapBase2) * trapHeight / 2;
std::cout << "The volume of the trapezoid is: " << trapVol << ", and the surface area of the trapezoid is: " << trapSurface << std::endl;
}
void elipArea()
{
float pi = 3.141592654;
float P = 1.6075;
float sideA = 0;
float sideB = 0;
float sideC = 0;
std::cout << "Please type in the length of side A: ";
std::cin >> sideA;
std::cout << "Please type in the length of side B: ";
std::cin >> sideB;
std::cout << "Please type in the length of side C: ";
std::cin >> sideC;
float ans = 4 * pi * (((sideA * P) * (sideB * P) + (sideA * P) * (sideC * P) + (sideB * P) * (sideC * P)) / 3) * 1 / P;
std::cout << "The surface area of the ellipsoid is: " << ans << std::endl;
}
void pyrVolume()
{
float base = 0;
float height = 0;
std::cout << "Please type in the side length of the pyramids base: ";
std::cin >> base;
std::cout << "Please type in the hight of the pyramid: ";
std::cin >> height;
float ans = (1 / 3) * (base * base) * height;
std::cout << "The volume fo the pyramid is: " << ans << std::endl;
}
void triPrisVolume()
{
float length = 0;
float height = 0;
float width = 0;
std::cout << "Please type in the width of the triangular prism: ";
std::cin >> width;
std::cout << "Please type in the height of the triangular prism: ";
std::cin >> height;
std::cout << "Please type in the length of the triangular prism: ";
std::cin >> length;
float ans = (1 / 2) * width * length * height;
std::cout << "The volume for the triangular prism is: " << ans << std::endl;
}
void cylVolume()
{
float pi = 3.141592654;
float radius = 0;
float height = 0;
std::cout << "Please type in the radius of the cylinder: ";
std::cin >> radius;
std::cout << "Please type in the height of the cylinder: ";
std::cin >> height;
float ans = pi * (radius * radius) * height;
std::cout << "The volume for the cylinder is: " << ans << std::endl;
}
void timeGravity()
{
float distance = 0;
float gravity = 0;
std::cout << "Please type in the distance of the object (in metres): ";
std::cin >> distance;
std::cout << "Please type in the level of gravity (in m/s2): ";
std::cin >> gravity;
float ans = sqrt((2 * distance) / gravity);
std::cout << "The time taken for the object to travel is: " << ans << " seconds" << std::endl;
}
void funChoice()
{
float choice = 0;
std::cout << "..." << std::endl;
std::cout << "Please type the number corresponding to the function" << std::endl;
std::cin >> choice;
if(choice == 1)
{
squareArea();
}
else if(choice == 2)
{
triangleArea();
}
else if(choice == 3)
{
circleArea();
}
else if(choice == 4)
{
circleCircumference();
}
else if(choice == 5)
{
cubeVolume();
}
else if(choice == 6)
{
cubeSurface();
}
else if(choice == 7)
{
trapSurfaceAndVolume();
}
else if(choice == 8)
{
elipArea();
}
else if(choice == 9)
{
pyrVolume();
}
else if(choice == 10)
{
triPrisVolume();
}
else if(choice == 11)
{
cylVolume();
}
else if(choice == 12)
{
timeGravity();
}
else
{
funChoice();
}
}
void main()
{
std::cout << "Welcome to the math calculator thing" << std::endl;
std::cout << "These are the currently available maths functions:" << std::endl;
std::cout << "1 -Area of a square" << std::endl;
std::cout << "2- Area of a triangle" << std::endl;
std::cout << "3- Area of a circle" << std::endl;
std::cout << "4- Circumference of a circle" << std::endl;
std::cout << "5- Volume of a cube" << std::endl;
std::cout << "6- Surface area of a cube" << std::endl;
std::cout << "7- Volume and Surface area of a trapezoid" << std::endl;
std::cout << "8- Area of an ellipsoid" << std::endl;
std::cout << "9- Volume of a square based pyramid" << std::endl;
std::cout << "10- Volume of a triangular prism" << std::endl;
std::cout << "11- Volume of a cylinder" << std::endl;
std::cout << "12- Time for an object to fall to the ground from a given height at given gravity in a vacuum" << std::endl;
funChoice();
}