BestTitan

Quick Physics v0.4.1

Sep 17th, 2024 (edited)
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.04 KB | Software | 0 0
  1. #include <bits/stdc++.h>
  2. #include <conio.h>
  3. using namespace std;
  4.  
  5. int menu(), notacion(), conversionUnidades(), componentesVector();
  6.  
  7. int printLogo(){
  8. cout << " _ _ \n/ " << char(92) <<" o _ | |_||_ " << char(92) << "/ _ o _ _\n" << char(92) <<"_X|_| | (_ |< | | | / _> | (_ _>\n";
  9. cout << "Quick Physics v0.4.1 - Best Titan (2024)\n\n";
  10. }
  11. // MENU PRINCIPAL
  12. int menu(){
  13. printLogo();
  14. int mode = 0;
  15. cout << "Escribe 1 para Notacion Cientifica\nEscribe 2 para Conversiones de Unidades\nEscribe 3 para Componentes de un Vector\n";
  16. cin >> mode;
  17. switch (mode){
  18. case 1:
  19. system("cls");
  20. notacion();
  21. break;
  22. case 2:
  23. system("cls");
  24. conversionUnidades();
  25. break;
  26. case 3:
  27. system("cls");
  28. componentesVector();
  29. break;
  30. default:
  31. cout << " // Valor invalido, ingrese porfavor un valor valido //";
  32. cout << endl << " // Presiona enter para volver al menu //";
  33. getch();
  34. system("cls");
  35. menu();
  36. }
  37.  
  38. }
  39.  
  40. // NOTACION CIENTIFICA
  41.  
  42. int notacion(){
  43. printLogo();
  44. int mode = 0; double n = 0; int aux = 0;
  45. cout << "Escribe 1 para convertir a notacion cientifica \nEscribe 2 para convertir a notacion desarrollada \n";
  46. cin >> mode;
  47. if (mode == 1){
  48. cout << "Escribe el numero que quieres convertir a notacion cientifica ";
  49. cin >> n;
  50. if (n < 1){
  51. while (n < 1){
  52. n *= 10;
  53. aux--;
  54. }
  55. } else {
  56. while (n > 9.9999){
  57. n /= 10;
  58. aux++;
  59. }
  60.  
  61. }
  62. cout << "\nTu numero en notacion cientifica es: " << n << " x10^" << aux << endl;
  63. cout << endl << endl << " // Presiona enter para volver al menu //";
  64. getch();
  65. system("cls");
  66. menu();
  67. } else if (mode == 2){
  68. cout << "Escribe el numero que quieres convertir a notacion desarrollada (solo el numero, sin el exponente) ";
  69. cin >> n;
  70. cout << "Escribe el exponente de 10 del numero a convertir a notacion desarrollada ";
  71. cin >> aux;
  72. if (aux > 0){
  73. while (aux > 0){
  74. n *= 10;
  75. aux --;
  76. }
  77. cout << "\nTu numero en notacion desarrollada es: "<< std::setprecision(0) << std::fixed << n; // para evitar que c++ automaticamente imprima con notacion cientifica
  78. cout << endl << endl << " // Presiona enter para volver al menu //";
  79. getch();
  80. system("cls");
  81. menu();
  82. } else {
  83. int aux1 = aux;
  84. while (aux < 0) {
  85. n /= 10;
  86. aux ++;
  87. }
  88. cout << "\nTu numero en notacion desarrollada es: "<< std::setprecision(abs(aux1)+2) << std::fixed << n;
  89. cout << endl << endl << " // Presiona enter para volver al menu //";
  90. getch();
  91. system("cls");
  92. menu();
  93. }
  94.  
  95. }
  96.  
  97. }
  98.  
  99. // CONVERSIONES DE UNIDADES (LONGITUD, MASA, VOLUMEN)
  100.  
  101. int conversionLongitud(), conversionMasa(), conversionVolumen();
  102.  
  103. int conversionUnidades(){
  104. printLogo();
  105. string m1, m2; int n, mode = 0;
  106. cout << "Escribe 1 para convertir unidades de longitud\nEscribe 2 para convertir unidades de masa\nEscribe 3 para convertir unidades de volumen\n";
  107. cin >> mode;
  108. switch (mode) {
  109. case 1:
  110. system("cls");
  111. conversionLongitud();
  112. break;
  113. case 2:
  114. system("cls");
  115. conversionMasa();
  116. break;
  117. case 3:
  118. system("cls");
  119. conversionVolumen();
  120. break;
  121. default:
  122. cout << " // Valor invalido, ingrese porfavor un valor valido //";
  123. cout << endl << " // Presiona enter para volver a Conversion de Unidades //";
  124. getch();
  125. system("cls");
  126. conversionUnidades();
  127. }
  128. }
  129.  
  130. int conversionLongitud(){
  131. printLogo();
  132. string convInput, convOutput; double n = 0, ans;
  133. cout << "Escribe la unidad de medida que quieres convertir (m, hm, cm, mm, km, yd, mi, ft, in) ";
  134. cin >> convInput;
  135. cout << "Escribe la unidad de medida a la que se va a convertir (m, hm, cm, mm, km, yd, mi, ft, in) ";
  136. cin >> convOutput;
  137. cout << "Escribe la cantidad a convertir (En numeros) ";
  138. cin >> n;
  139. ans = n;
  140. if (convInput == "m"){
  141. if(convOutput == "cm") ans *= 100;
  142. if(convOutput == "hm") ans /= 100;
  143. if(convOutput == "mm") ans *= 1000;
  144. if(convOutput == "km") ans /= 1000;
  145. if(convOutput == "yd") ans *= 1.093;
  146. if(convOutput == "ft") ans *= 3.279;
  147. if(convOutput == "in") ans /= 0.0254;
  148. if(convOutput == "mi") ans /= 1609;
  149. }
  150. if (convInput == "hm"){
  151. if(convOutput == "m") ans *= 100;
  152. if(convOutput == "cm") ans *= 10000;
  153. if(convOutput == "mm") ans *= 100000;
  154. if(convOutput == "km") ans /= 10;
  155. if(convOutput == "yd") ans *= 109.3;
  156. if(convOutput == "ft") ans *= 327.9;
  157. if(convOutput == "in") ans *= 3937;
  158. if(convOutput == "mi") ans /= 16.09;
  159. }
  160. if (convInput == "cm"){
  161. if(convOutput == "m") ans /= 100;
  162. if(convOutput == "hm") ans /= 10000;
  163. if(convOutput == "mm") ans *= 10;
  164. if(convOutput == "km") ans /= 100000;
  165. if(convOutput == "yd") ans /= 91.44;
  166. if(convOutput == "ft") ans /= 30.48;
  167. if(convOutput == "in") ans /= 2.54;
  168. if(convOutput == "mi") ans /= 160934;
  169. }
  170. if (convInput == "mm"){
  171. if(convOutput == "m") ans /= 1000;
  172. if(convOutput == "hm") ans /= 100000;
  173. if(convOutput == "cm") ans /= 10;
  174. if(convOutput == "km") ans /= 1000000;
  175. if(convOutput == "yd") ans /= 914.4;
  176. if(convOutput == "ft") ans /= 304.8;
  177. if(convOutput == "in") ans /= 25.4;
  178. if(convOutput == "mi") ans /= 1609344;
  179. }
  180. if (convInput == "km"){
  181. if(convOutput == "m") ans *= 1000;
  182. if(convOutput == "hm") ans *= 10;
  183. if(convOutput == "cm") ans *= 100000;
  184. if(convOutput == "mm") ans *= 1000000;
  185. if(convOutput == "yd") ans *= 1093.61;
  186. if(convOutput == "ft") ans *= 3280.84;
  187. if(convOutput == "in") ans *= 39370;
  188. if(convOutput == "mi") ans /= 1.60934;
  189. }
  190. if (convInput == "yd"){
  191. if(convOutput == "m") ans *= 0.9144;
  192. if(convOutput == "hm") ans /= 109.361;
  193. if(convOutput == "cm") ans *= 91.44;
  194. if(convOutput == "mm") ans *= 914.4;
  195. if(convOutput == "km") ans /= 1093.61;
  196. if(convOutput == "ft") ans *= 3;
  197. if(convOutput == "in") ans *= 36;
  198. if(convOutput == "mi") ans /= 1.760;
  199. }
  200. if (convInput == "ft"){
  201. if(convOutput == "m") ans *= 0.3048;
  202. if(convOutput == "hm") ans /= 328.084;
  203. if(convOutput == "cm") ans *= 30.48;
  204. if(convOutput == "mm") ans *= 304.8;
  205. if(convOutput == "km") ans /= 3280.84;
  206. if(convOutput == "yd") ans /= 3;
  207. if(convOutput == "in") ans *= 12;
  208. if(convOutput == "mi") ans /= 5280;
  209. }
  210. if (convInput == "in"){
  211. if(convOutput == "m") ans *= 0.0254;
  212. if(convOutput == "hm") ans /= 3937.01;
  213. if(convOutput == "cm") ans *= 2.54;
  214. if(convOutput == "mm") ans *= 25.4;
  215. if(convOutput == "km") ans /= 39370.1;
  216. if(convOutput == "yd") ans /= 36;
  217. if(convOutput == "in") ans /= 12;
  218. if(convOutput == "mi") ans /= 63360;
  219. }
  220. if (convInput == "mi"){
  221. if(convOutput == "m") ans *= 1609.34;
  222. if(convOutput == "hm") ans *= 16.0934;
  223. if(convOutput == "cm") ans *= 160934;
  224. if(convOutput == "mm") ans *= 1609344;
  225. if(convOutput == "km") ans *= 1.60934;
  226. if(convOutput == "yd") ans *= 1760;
  227. if(convOutput == "in") ans *= 5280;
  228. if(convOutput == "in") ans *= 63360;
  229. }
  230.  
  231. cout << endl << n << convInput << " equivale a " << ans << convOutput;
  232. cout << endl << endl << " // Presiona enter para volver al menu //";
  233. getch();
  234. system("cls");
  235. menu();
  236. }
  237.  
  238.  
  239.  
  240. int conversionMasa(){
  241. printLogo();
  242. string convInput, convOutput; double n = 0, ans;
  243. cout << "Escribe la unidad de masa que quieres convertir (kg, g, lb, ton, on) ";
  244. cin >> convInput;
  245. cout << "Escribe la unidad de masa a la que se va a convertir (kg, g, lb, ton, on) ";
  246. cin >> convOutput;
  247. cout << "Escribe la cantidad a convertir (En numeros) ";
  248. cin >> n;
  249. ans = n;
  250. if (convInput == "kg"){
  251. if(convOutput == "g") ans *= 1000;
  252. if(convOutput == "lb") ans *= 2.20462;
  253. if(convOutput == "ton") ans /= 1000;
  254. if(convOutput == "on") ans *= 35.274;
  255. }
  256. if (convInput == "g"){
  257. if(convOutput == "kg") ans /= 1000;
  258. if(convOutput == "lb") ans /= 453.592;
  259. if(convOutput == "ton") ans /= 1000000;
  260. if(convOutput == "on") ans /= 28.3495;
  261. }
  262. if (convInput == "lb"){
  263. if(convOutput == "kg") ans /= 2.20462;
  264. if(convOutput == "g") ans *= 453.592;
  265. if(convOutput == "ton") ans /= 2204.62;
  266. if(convOutput == "on") ans *= 16;
  267. }
  268. if (convInput == "ton"){
  269. if(convOutput == "kg") ans *= 1000;
  270. if(convOutput == "g") ans *= 1000000;
  271. if(convOutput == "lb") ans *= 2204.62;
  272. if(convOutput == "on") ans *= 35274;
  273. }
  274. if (convInput == "on"){
  275. if(convOutput == "kg") ans /= 35.274;
  276. if(convOutput == "g") ans *= 28.3495;
  277. if(convOutput == "lb") ans /= 16;
  278. if(convOutput == "ton") ans /= 35274;
  279. }
  280. cout << endl << n << convInput << " equivale a " << ans << convOutput;
  281. cout << endl << endl << " // Presiona enter para volver al menu //";
  282. getch();
  283. system("cls");
  284. menu();
  285. }
  286.  
  287.  
  288. int conversionVolumen(){
  289. printLogo();
  290. string convInput, convOutput; double n = 0, ans;
  291. cout << "Escribe la unidad de volumen que quieres convertir (l, ml, cm3, dm3, m3, gal) ";
  292. cin >> convInput;
  293. cout << "Escribe la unidad de volumen a la que se va a convertir (l, ml, cm3, dm3, m3, gal) ";
  294. cin >> convOutput;
  295. cout << "Escribe la cantidad a convertir (En numeros) ";
  296. cin >> n;
  297. ans = n;
  298. if (convInput == "cm3"){
  299. if(convOutput == "ml") ans *= 1;
  300. if(convOutput == "l") ans /= 1000;
  301. if(convOutput == "dm3") ans /= 1000;
  302. if(convOutput == "m3") ans /= 1000000;
  303. if(convOutput == "gal") ans /= 3785.41;
  304. }
  305. if (convInput == "ml"){
  306. if(convOutput == "cm3") ans *= 1;
  307. if(convOutput == "l") ans /= 1000;
  308. if(convOutput == "dm3") ans /= 1000;
  309. if(convOutput == "m3") ans /= 1000000;
  310. if(convOutput == "gal") ans /= 3785.41;
  311. }
  312. if (convInput == "l"){
  313. if(convOutput == "ml") ans *= 1000;
  314. if(convOutput == "cm3") ans *= 1000;
  315. if(convOutput == "dm3") ans *= 1;
  316. if(convOutput == "m3") ans /= 1000;
  317. if(convOutput == "gal") ans /= 3.78541;
  318. }
  319. if (convInput == "dm3"){
  320. if(convOutput == "ml") ans *= 1000;
  321. if(convOutput == "cm3") ans *= 1000;
  322. if(convOutput == "l") ans *= 1;
  323. if(convOutput == "m3") ans /= 1000;
  324. if(convOutput == "gal") ans /= 3.78541;
  325. }
  326. if (convInput == "m3"){
  327. if(convOutput == "ml") ans *= 1000000;
  328. if(convOutput == "cm3") ans *= 1000000;
  329. if(convOutput == "dm3") ans *= 1000;
  330. if(convOutput == "l") ans *= 1000;
  331. if(convOutput == "gal") ans *= 264.172;
  332. }
  333. if (convInput == "gal"){
  334. if(convOutput == "ml") ans *= 3785.41;
  335. if(convOutput == "cm3") ans *= 3785.41;
  336. if(convOutput == "dm3") ans *= 3.78541;
  337. if(convOutput == "l") ans *= 3.78541;
  338. if(convOutput == "m3") ans /= 264.172;
  339. }
  340. cout << endl << n << convInput << " equivale a " << ans << convOutput;
  341. cout << endl << endl << " // Presiona enter para volver al menu //";
  342. getch();
  343. system("cls");
  344. menu();
  345. }
  346.  
  347.  
  348. // COMPONENTES DE UN VECTOR
  349.  
  350. int componentesVector(){
  351. printLogo();
  352. int F, n, cuadrante;
  353. char sentido;
  354. cout << "Escribe la cantidad de la fuerza del vector "; cin >> F;
  355. cout << "Escribe el angulo de la fuerza del vector "; cin >> n;
  356. cout << "Escribe el cuadrante en el que se encuentra el angulo en el vector "; cin >> cuadrante;
  357. cout << "Escribe 'a' si el sentido del angulo es antihorario, y 'h' si es horario "; cin >> sentido;
  358.  
  359. int anguloReal = ((sentido == 65) || (sentido == 97) ? n : 90-n)+90*(cuadrante-1);
  360. cout << "El angulo real es: " << anguloReal << endl;
  361. cout << "Fx = " << std::setprecision(4) << std::fixed << F*cos(anguloReal* 3.14159265 / 180) << endl; // grados a radiales?
  362. cout << "Fy = " << std::setprecision(4) << std::fixed << F*sin(anguloReal* 3.14159265 / 180); // grados a radiales?
  363. cout << endl << endl << " // Presiona enter para volver al menu //";
  364. getch();
  365. system("cls");
  366. menu();
  367.  
  368.  
  369.  
  370. }
  371.  
  372.  
  373.  
  374. int main(){
  375. menu();
  376. }
  377.  
Advertisement
Add Comment
Please, Sign In to add comment