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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int w = 1;
double gamma;
double gammaA;
double gammaB;
double beta;
double betaSQ;
double C = 299792458;
double CSQ = 89875517873681764;
double Gc = 6.67384 / 100000000000;
double Ge = 9.78;
double G;
double V;
double Va;
double Vb;
double VSQ;
double VCU;
double Vstr;
double Vend;
double length;
double M;
double Mr;
double Mn;
double A;
double F;
double T;
double Ep;
double Em;
double Ek;
double Et;
double x;
double y;
double z;
double a;
double b;
double c;
while (w == 1){
cout << "all variables are metric (meters, seconds, newtons, kilograms, joules) \n";
cout << "relative 1 or newtonian 2 \n";
cin >> y;
if (y == 1){
cout << "solve for gamma 1, beta 2, gravity 3, mass 4, acceleration 5, force 6, time 7, mass energy 8, kinetic energy 9, total energy 10 \n";
cin >> x;
if (x == 1) {
cout << "input beta \n";
cin >> beta;
betaSQ = beta * beta;
gammaA = 1 - betaSQ;
gammaB = sqrt(gammaA);
gamma = 1 / gammaB;
cout << "\ngamma is " << gamma;
}
else if (x == 2) {
cout << "input velocity \n";
cin >> V;
beta = V / C;
cout << "\nbeta is " << beta;
}
else if (x == 3) {
}
else if (x == 4) {
cout << "rest mass 1 or moving mass 2 \n";
cin >> z;
if (z == 1) {
cout << "mass energy 1 or total energy 2 \n";
cin >> a;
if (a == 1) {
cout << "input mass energy \n";
cin >> Em;
Mn = Em / CSQ;
cout << "\nthe rest mass is " << Mn;
}
else {
cout << "input total energy \n";
cin >> Et;
cout << "\ninput gamma \n";
cin >> gamma;
cout << "\ninput velocity \n";
cin >> velocity;
Em = (Et / gamma) / V;
Mn = Em / CSQ;
cout << "\nthe rest mass is " << Mn;
}
}
else {
}
}
else if (x == 5) {
}
else if (x == 6) {
}
else if (x == 7) {
}
else if (x == 8) {
cout << "input rest mass \n";
cin >> Mn;
Em = M * CSQ;
cout << "\nthe mass energy is " << CSQ;
}
else if (x == 9) {
cout << "input gamma \n";
cin >> gamma;
cout << "\ninput rest mass \n";
cin >> Mn;
cout << "\ninput V \n";
cin >> V;
Em = Mn * CSQ;
Et = Em * gamma * V;
Ek = Et - Em;
cout << "\nthe kinetic energy is " << Ek;
}
else {
cout << "input gamma \n";
cin >> gamma;
cout << "\ninput rest mass \n";
cin >> Mn;
cout << "\ninput velocity \n";
cin >> V;
Em = Mn * CSQ;
Et = Em * gamma * V;
cout << "\nthe total energy is " << Et;
}
}
else {
cout << "solve for velocity 1, mass 2, acceleration 3, force 4, time 5, kinetic energy 6, gravity 7 \n";
cin >> x;
if (x == 1) {
cout << "timed acceleration 1 or kinetic energy and mass 2 \n";
cin >> z;
if (z == 1) {
cout << "input time \n";
cin >> T;
cout << "\ninput acceleration \n";
cin >> A;
V = A * T;
cout << "\nthe velocity is " << V;
}
else {
cout << "input mass \n";
cin >> M;
cout << "\ninput kinetic energy \n";
cin >> Ek;
Va = Ek / M;
Vb = Va * 2;
V = sqrt (Vb);
cout << "\nthe velocity is " << V;
}
}
else if (x == 2) {
cout << "input kinetic energy \n";
cin >> Ek;
cout << "\ninput velocity \n";
cin >> V;
VSQ = V * V;
M = Ek * 2 / VSQ;
cout << "\nthe mass is " << M;
}
else if (x == 3) {
cout << "input force \n";
cin >> F;
cout << "\ninput mass \n";
cin >> M;
A = F / M;
cout << "\nthe acceleration is " << A;
}
else if (x == 4) {
cout << "input mass \n";
cin >> M;
cout << "\ninput acceleration \n";
cin >> A;
F = M * A;
cout << "\nthe force is " << F;
}
else if (x == 5) {
cout << "input acceleration \n";
cin >> A;
cout << "\ninput start velocity \n";
cin >> Vstr;
cout << "\ninput velocity end \n";
cin >> Vend;
V = Vend - Vstr;
T = A / V;
cout << "\nthe time is " << T;
}
else if (x == 6) {
cout << "input velocity \n";
cin >> V;
cout << "\ninput mass \n";
cin >> M;
VSQ = V * V;
Ek = VSQ * M / 2;
cout << "\nthe kinetic energy is " << Ek;
}
else {
cout << "graitational force 1, potential energy 2, or acceleration 3 \n";
cin >> z;
if (z == 1) {
cout << "\ninput mass \n";
cin >> M;
cout << "\ninput other mass \n";
cin >> Mn;
cout << "\ninput distance \n";
cin >> length;
G = M * Mn * Gc / (length * length);
cout << "\nthe gravitational force is " << G;
}
else if (z == 2) {
cout << "\ntotal potential energy 1, lengthed/timed fall 2, or lengthed/timed fall on earth 3 \n";
cin >> a;
if (a == 1) {
}
else if (a == 2) {
cout << "\n potential energy 1, end veloctiy 2, or average veloctiy 3 \n";
cin >> b;
if (b == 1) {
cout << "\ninput gravitation \n";
cin >> G;
cout << "\ninput fall length \n";
cin >> length;
cout << "\ninput mass \n";
cin >> M;
Ep = G * length * M;
cout << "\nthe potential energy is " << Ep;
}
else if (b == 2) {
cout << "\ntime 1 or length 2 \n";
cin >> c;
if (c == 1) {
cout << "\ninput fall time \n";
cin >> T;
cout << "\ninput gravitation \n";
cin >> G;
length = G * T * T / 2;
Ep = G * length;
VSQ = Ep * 2;
V = sqrt(VSQ);
cout << "\nthe end velocity is " << V;
}
|