1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;
void clearBuffer()
{
cin.clear();
cin.ignore( numeric_limits< streamsize >::max(), '\n' );
}
int radius;
double pi = 3.14159265358979323846;
double a;
double b;
double c;
double v;
double w;
double x;
double y;
double x1;
double x2;
double x3;
double y11 = y * v;
double y2 = w * x;
double y3 = y11 - y2;
double answer1;
double answer2;
double answer3 = answer1 - answer2;
double yfinal = answer3 / y3;
double xtimesx = answer1 - (yfinal * y);
double finalanswer;
double xfinalanswer = xtimesx / x;
char choice;
double addition (double a, double b)
{
return (a+b);
}
double subtraction (double a, double b)
{
return (a-b);
}
double multiplication (double a, double b)
{
return (a*b);
}
double division (double a, double b)
{
return (a/b);
}
double quadratica (double a, double b, double c)
{
return (-b + sqrt(b*b - 4*a*c))/(2 * a);
}
double quadraticb (double a, double b, double c)
{
return (-b - sqrt(b*b - 4*a*c))/(2 * a);
}
double circle_area_function (double radius)
{
return (pi*(radius * radius));
}
double circumference_function (double radius)
{
return (2 * pi * radius);
}
int main(){
cout << "Welcome to the Maths Problem solver, this program has been designed to work out answers for you." << endl;
cout << "Pick which kind of formulae do you want to use:" << endl;
cout << "1) ax^2 + bx + c = 0" << endl;
cout << "2) pi*r^2" << endl;
cout << "3) 2 * pi * r" << endl;
cout << "4) a+b" << endl;
cout << "5) a-b" << endl;
cout << "6) a*b" << endl;
cout << "7) a/b" << endl;
cout << "8) Simultaneous equations" << endl;
cin >> choice;
{
clearBuffer();
}
if (choice == '1'){
cout << "Input your a:" << endl;
cin >> a;
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "Input your b:" << endl;
cin >> b;
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
cout << "input your c:" << endl;
cin >> c;
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
{
double x;
x = quadratica (a,b,c);
cout << "Your first answer is " << x << endl;
}
{
double y;
y = quadraticb (a,b,c);
cout << "Your second answer is " << y << endl;
}
}
if (choice == '2'){
cout << "Input your radius." << endl;
cin >> radius;
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
{
double circle_area;
circle_area = circle_area_function (radius);
cout << "Your answer is " << circle_area << endl;
}
}
if (choice == '3'){
cout << "Insert your radius." << endl;
cin >> radius;
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
{
double circumference;
circumference = circumference_function (radius);
cout << "Your answer is " << circumference << endl;
}
}
if (choice == '4'){
cout << "Insert your a." << endl;
cin >> a;
cout << "Insert your b." << endl;
cin >> b;
{
double addition_answer;
addition_answer = addition (a, b);
cout << "Your answer is " << addition_answer << endl;
}
}
if (choice == '5'){
cout << "Insert your a." << endl;
cin >> a;
cout << "Insert your b." << endl;
cin >> b;
{
double subtraction_answer;
subtraction_answer = subtraction (a, b);
cout << "Your answer is " << subtraction_answer << endl;
}
}
if (choice == '6'){
cout << "Insert your a." << endl;
cin >> a;
cout << "Insert your b." << endl;
cin >> b;
{
double multiplication_answer;
multiplication_answer = multiplication (a, b);
cout << "Your answer is " << multiplication_answer << endl;
}
}
if (choice == '7'){
cout << "Insert your a." << endl;
cin >> a;
cout << "Insert your b." << endl;
cin >> b;
{
double division_answer;
division_answer = division (a, b);
cout << "Your answer is " << division_answer << endl;
}
}
if (choice == '8'){
cout << "Insert your first x." << endl;
cin >> x;
cout << "Insert your first y." << endl;
cin >> y;
cout << "Insert your second x." << endl;
cin >> v;
cout << "Insert your second y." << endl;
cin >> w;
cout << "Insert your first answer." << endl;
cin >> answer1;
cout << "Insert yout second answer." << endl;
cin >> answer2;
cout << "Your answer is " << xfinalanswer << " and " << yfinal << endl;
}
system("pause");
}
|