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
|
#include <iostream>
#include "conio.h"
#include <string>
#include <cmath>
#include <math.h>
using namespace std;
// this variable is to choose what function a person wants to do
int mainfunction = 0;
/* !!!!!!!!!!These next variables are for the division of polynomials function !!!!!!!!!!!!!!!!!*/
int checkinputspecial;
int firstchoice = 0; // determines degree of divident (thing being divided)
int secondchoice = 0; // determines degree of divisor
int dive [7] = { 0, 0, 0, 0, 0, 0, 0 } ; // this is your dividend, if its a 3 degree polynomial, you will only use 3 of the alloted variables etc.
int divi [6] = { 0, 0, 0, 0, 0, 0 }; // this is your divisor, to be used for any degree divisor
int quo [6] = { 0, 0, 0, 0, 0, 0 };// this is going to be your quotient that ends up on top of the dividend
int line [8][7]; /* These are your subtraction lines. the first box denotes sequence from top to bottom.
second box denotes space in that line from left to right, as if you were doing this division by hand
and drew a graph around the various inputs under the dividend*/
int abso [5];// these are to be used for when you need to convert a 'line [x][x]' into its absolute value
int rem2 [3] ;// no use yet
int result [7] ;// no use yet
int check_input1 = 1;// to find out if dive input is correct
int check_input2 = 1;// to find out if divi input is correct
int dive1 [5];// not used yet
/* !!!!!!these next variables are for the quadratic formula function!!!!!!!!!!!!!*/
float a, b, c;
double d = (b / -1);
double e = (b * b);
double f = 4 * a * c;
double t = e - f;
double y = sqrt(t / -1);
double u = d + y;
double g = 2 * a;
double h = (d + y) / g;
/* these variables are for the circle function!!!!!!!! */
int circlefunction;
double radius = 0;
double PI = 3.1415932;
double circumferance = (2 * PI * radius);
double area = (PI * (radius * radius));
double timesaround = 0;
double time = 0;
double totaldistance = 0;
double speed = 0;
int main()
{
cout << " hello \n \n \n " << endl;
cout << " welcome to Johnny's calculator \n" << endl;
cout << " this calculator can do a few things and more are always being added \n \n" << endl;
cout << " right now we can either \n" << endl;
cout << "1.) use the quadratic formula to find the zeroes of a quadratic polynomial \n " << endl;
cout << "2.) divide polynomials of various degree's into one another \n" << endl;
cout << "3.) do equations based on the relations of a circle \n \n " << endl;
cout << "please choose what you would like to do ( 1 2, 3 ) " << endl;
cin >> mainfunction;
cout << " \n \n \n \n \n \n " << endl;
if (mainfunction < 1 && mainfunction > 3)
{
return main();
}
if (mainfunction == 1)
{
cout << " today we will find the zeroes of a quadratic using the quadratic formula" << endl;
cout << " it will be in this form. " << endl;
cout << " \n \n Ax^2 + Bx + C \n \n \n" << endl;
cout << "please enter your 'a' term" << endl;
cin >> a;
cout << "please enter your b term" << endl;
cin >> b;
cout << "please enter your constant (c term)" << endl;
cin >> c;
cout << "your polynomial is " << a <<"x^2 +" << b << "x +" << c << endl;
double d = (b / -1);
double e = (b * b);
double f = 4 * a * c;
double t = e - f;
double y = sqrt (t / -1);
double u = sqrt (t);
double g = 2 * a;
if (t < 0)
{
cout << " the zero's of your polynomial are " << d << " +/- " << y << "i" << "/" << g << " \n \n " << endl;
cout << "this reduces to " << d / g << " + " << y << "i" << " / " << g << " \n \n " <<endl;
cout << "and " << d / g << " - " << y << "i" << "/" << g << " \n \n \n \n \n \n \n \n" << endl;
system("PAUSE");
}
if (t > 0)
{
cout << " the zero's of your polynomial are " << d / g << " +/- " << u / g << " \n \n " << endl;
cout << "this reduces to " << (d / g) + ( u / g) << " and " << (d / g) - (u / g) << " \n \n \n" << endl;
system("PAUSE");
}
return main();
}
if (mainfunction == 2)
{
cout << " today we will be dividing two polynomials together \n" ;
cout << " \n ";
cout << " it will be in this form; \n" ;
cout << " \n ";
cout << " ax^3+ bx^2+ cx+ d / ax^2+bx+c \n " ;
cout << " \n" ;
cout << "with varying numbers for both the degree of the polynomial and the coeffecients \n" ;
cout << " \n";
cout << " please select the degree of your dividend ( 2 < x < 4 ) \n" << endl;
cout << " ( the dividend is the number being divided into ) " << endl; // select degree of dividend
cout << " ( the divisor is the number the dividend is divided by ) " << endl;
cout << " \n ";
cin >> firstchoice;
if (firstchoice < 2 || firstchoice > 4) // incase they enter a degree to high for my programming skills
{
cout << endl << "please choose a dividend of degree 3 or 4 "; cin >> firstchoice;
}
if (firstchoice == 3)
{
cout << "what is the degree of your divisor? (1 or 2) \n";
cin >> secondchoice;
if (secondchoice == 1) /* this is for a 3rd degree plynml being divided by a 1st degree plynml, in the form "Ax+B"*/
{
cout << "you said your dividend is a 3rd degree polynomial, this will be in the form \n" ;
cout << " \n ";
cout << " Ax^3 + Bx^2 + Cx + D \n " ;
cout << "D is your constant term \n";
cout << " \n ";
cout << "please enter in the corresponding coeffecients as they logically \n " << endl;
cout << "appear on screen. numbers must be whole intergers\n " << endl ;
cout << " \n " << endl;
cout << "please enter the proper coeffecients for the corresponding terms below \n";
cout << " \n ";
cout <<" Ax^3 + Bx^2 + Cx + D \n \n \n";
cout << " \n ";
cout << "A term ="; cin >> dive [0]; cout << dive [0] << endl;
cout << " \n ";
cout << "B term ="; cin >> dive [1]; cout << dive [1] << endl;
cout << " \n ";
cout << "C term ="; cin >> dive [2]; cout << dive [2] << endl;
cout << " \n ";
cout << "D term (constant) ="; cin >> dive [3]; cout << dive [3] << endl;
cout << " \n ";
cout << "your polynomial is \n";
cout << " \n ";
cout << " " << dive [0] << "x^3 + " << dive [1] << "x^2 + " << dive [2] << "x + " << dive [3] << endl;
cout << "is this correct (0 for NO, anything else for YES)" << endl;// to make sure input is correct
cin >> check_input1;
cout << " \n \n \n \n \n \n \n " << endl;
if (check_input1 == 0)
{
cout << "re-enter your A,B,C, and D term, one by one. hitting enter after each one \n" << endl;
cin >> dive [0];
cin >> dive [1];
cin >> dive [2];
cin >> dive [3];
cout << "your dividend polynomial is \n";
cout << dive [0] << "x^3 + " << dive [1] << "x^2 + " << dive [2] << "x + " << dive [3] << endl;
cout << " \n \n \n \n \n \n \n " << endl;
check_input1 = 2;/* makes it so whatever they enter in the second time gets automatically passed onto the divisor
input*/
}
|