Guest User

Untitled

a guest
Oct 16th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.97 KB | None | 0 0
  1. package Trabajo;
  2. import javax.swing.JOptionPane;
  3.  
  4. public class Proyecto
  5. {
  6. /**
  7. * Metodo inicial.
  8. */
  9. public static void main(String[] args)
  10. {
  11. try
  12. {
  13. int operacion = Integer.parseInt(JOptionPane.showInputDialog("Ingrese una opcion \n"
  14. + "1-Conversion \n"
  15. + "2-Suma \n"
  16. + "3-Resta \n"
  17. + "4-Multiplicacion"));
  18. menuInicio(operacion);
  19. }
  20. catch (Exception err)
  21.  
  22. {
  23. JOptionPane.showMessageDialog(null, "Error","rango Invalido!",JOptionPane.ERROR_MESSAGE);
  24. }
  25. }
  26.  
  27. /**
  28. * Aplicacion para Convercion,sumar,resta o multiplicar Sistemas numericos
  29. *
  30. * @param operacion
  31. * Codigo es de la opreacion
  32. * @Autor: Diego Fernando Echverry
  33. * @Autor: Pedro Holguin
  34. */
  35. //menu Inicio
  36. public static void menuInicio(int operacion)
  37. {
  38.  
  39. if (operacion >= 1 && operacion <= 4)
  40. {
  41. try
  42. {
  43. switch (operacion)
  44. {
  45. // Conversion
  46. case 1:
  47. int baseOrigen = menuBase(-1);
  48.  
  49. String numeroIngresado = ingresarNumero();
  50. int baseDestino = menuBase(baseOrigen);
  51. JOptionPane.showMessageDialog(null,convertirNumeroBase(baseOrigen,
  52. baseDestino, numeroIngresado));
  53.  
  54. break;
  55.  
  56. // Suma
  57. case 2:
  58. int baseOperacion = menuBase(-1);
  59. String[] datosOperacion = ingresarDatosOperacion();
  60. JOptionPane.showMessageDialog(null,sumar(
  61. datosOperacion[0],
  62. datosOperacion[1],
  63. baseOperacion));
  64. break;
  65. // Resta
  66. case 3:
  67. int baseOperacionResta = menuBase(-1);
  68. String[] datosOperacionResta = ingresarDatosOperacion();
  69.  
  70. JOptionPane.showMessageDialog(null,restar(
  71. datosOperacionResta[0],
  72. datosOperacionResta[1],
  73. baseOperacionResta));
  74. break;
  75.  
  76. // Multiplicacion
  77. case 4:
  78. int baseOperacionMultiplicacion = menuBase(-1);
  79. String[] datosOperacionMultiplicacion = ingresarDatosOperacion();
  80.  
  81. JOptionPane.showMessageDialog(null,Multiplicar(
  82. datosOperacionMultiplicacion[0],
  83. datosOperacionMultiplicacion[1],
  84. baseOperacionMultiplicacion));
  85. break;
  86. }
  87.  
  88. } catch (Exception err)
  89. {
  90. JOptionPane.showMessageDialog(null, "Error",
  91. "rango Invalido!",
  92. JOptionPane.ERROR_MESSAGE);
  93. }
  94. } else
  95. {
  96. JOptionPane.showMessageDialog(null, "No esta entre las obciones del Menu", "Error!",
  97. JOptionPane.ERROR_MESSAGE);
  98. }
  99. }
  100.  
  101. /**
  102. *
  103. * @param primerOperando
  104. * @param segundoOperando
  105. * @param baseOperacion
  106. * @return
  107. */
  108. private static String sumar(String primerOperando, String segundoOperando,
  109. int baseOperacion)
  110. {
  111.  
  112. String retorno = "Resultado Suma: ";
  113. try {
  114. switch (baseOperacion)
  115. {
  116. // Binario
  117. case 1:
  118. retorno += sumarBinarios(primerOperando, segundoOperando);
  119. break;
  120. // Octal
  121. case 2:
  122. retorno += sumarOctal(primerOperando, segundoOperando);
  123. break;
  124.  
  125. // Decimal
  126. case 3:
  127. retorno += sumarDecimal(primerOperando, segundoOperando);
  128. break;
  129.  
  130. // Hexadecimal
  131. case 4:
  132. retorno += sumarHexadecimal(primerOperando, segundoOperando);
  133. break;
  134. }
  135. } catch (Exception err)
  136. {
  137. JOptionPane.showMessageDialog(null, "Error",
  138. "Has introducido carcateres invalidos!",
  139. JOptionPane.ERROR_MESSAGE);
  140. }
  141. return retorno;
  142. }
  143.  
  144. // Sumar Binarios
  145. private static String sumarBinarios(String primerOperando,
  146. String segundoOperando)
  147. {
  148. String primerBinario = convertirBinarioADecimal(primerOperando);
  149. String segundoBinario = convertirBinarioADecimal(segundoOperando);
  150. int primero = Integer.parseInt(primerBinario);
  151. int segundo = Integer.parseInt(segundoBinario);
  152. int operacion = primero + segundo;
  153. String resultado = "" + operacion;
  154. return convertirDecimalABinario(resultado);
  155. }
  156.  
  157. // Sumar Octal
  158. private static String sumarOctal(String primerOperando,
  159. String segundoOperando)
  160. {
  161. String primerOctal = convertirOctalADecimal(primerOperando);
  162. String segundoOctal = convertirOctalADecimal(segundoOperando);
  163. int primero = Integer.parseInt(primerOctal);
  164. int segundo = Integer.parseInt(segundoOctal);
  165. int operacion = primero + segundo;
  166. String resultado = "" + operacion;
  167. return convertirDecimalAoctal(resultado);
  168. }
  169.  
  170. // sumar Decimal
  171. private static String sumarDecimal(String primerOperando,
  172. String segundoOperando)
  173. {
  174. int primero = Integer.parseInt(primerOperando);
  175. int segundo = Integer.parseInt(segundoOperando);
  176. int operacion = primero + segundo;
  177. String resultado = "" + operacion;
  178. return resultado;
  179. }
  180.  
  181. // sumar hexadecimal
  182. private static String sumarHexadecimal(String primerOperando,
  183. String segundoOperando)
  184. {
  185. String primerOctal = convertirHexadecimalADecimal(primerOperando);
  186. String segundoOctal = convertirHexadecimalADecimal(segundoOperando);
  187. int primero = Integer.parseInt(primerOctal);
  188. int segundo = Integer.parseInt(segundoOctal);
  189. int operacion = primero + segundo;
  190. String resultado = "" + operacion;
  191. return convertirDecimalAhexadecimal(resultado);
  192. }
  193.  
  194. /**
  195. *
  196. * @param primerOperando
  197. * @param segundoOperando
  198. * @param baseOperacion
  199. * @return
  200. */
  201. private static String restar(String primerOperando, String segundoOperando,
  202. int baseOperacion)
  203. {
  204.  
  205. String retorno = "Resultado Resta: ";
  206.  
  207. switch (baseOperacion)
  208. {
  209. // Binario
  210. case 1:
  211. retorno += restarBinarios(primerOperando, segundoOperando);
  212. break;
  213. // Octal
  214. case 2:
  215. retorno += restarOctal(primerOperando, segundoOperando);
  216. break;
  217.  
  218. // Decimal
  219. case 3:
  220. retorno += restarDecimal(primerOperando, segundoOperando);
  221. break;
  222.  
  223. // Hexadecimal
  224. case 4:
  225. retorno += restarHexadecimal(primerOperando, segundoOperando);
  226. break;
  227. }
  228.  
  229. return retorno;
  230. }
  231.  
  232. // resta Binarios
  233. private static String restarBinarios(String primerOperando,
  234. String segundoOperando) {
  235. String primerBinario = convertirBinarioADecimal(primerOperando);
  236. String segundoBinario = convertirBinarioADecimal(segundoOperando);
  237. int primero = Integer.parseInt(primerBinario);
  238. int segundo = Integer.parseInt(segundoBinario);
  239. int operacion = primero - segundo;
  240. String resultado = "" + operacion;
  241. return convertirDecimalABinario(resultado);
  242. }
  243.  
  244. // restar Octal
  245. private static String restarOctal(String primerOperando,
  246. String segundoOperando) {
  247. String primerOctal = convertirOctalADecimal(primerOperando);
  248. String segundoOctal = convertirOctalADecimal(segundoOperando);
  249. int primero = Integer.parseInt(primerOctal);
  250. int segundo = Integer.parseInt(segundoOctal);
  251. int operacion = primero - segundo;
  252. String resultado = "" + operacion;
  253. return convertirDecimalAoctal(resultado);
  254. }
  255.  
  256. // restar Decimal
  257. private static String restarDecimal(String primerOperando,
  258. String segundoOperando) {
  259. int primero = Integer.parseInt(primerOperando);
  260. int segundo = Integer.parseInt(segundoOperando);
  261. int operacion = primero - segundo;
  262. String resultado = "" + operacion;
  263. return resultado;
  264. }
  265.  
  266. // restar hexadecimal
  267. private static String restarHexadecimal(String primerOperando,
  268. String segundoOperando) {
  269. String primerOctal = convertirHexadecimalADecimal(primerOperando);
  270. String segundoOctal = convertirHexadecimalADecimal(segundoOperando);
  271. int primero = Integer.parseInt(primerOctal);
  272. int segundo = Integer.parseInt(segundoOctal);
  273. int operacion = primero - segundo;
  274. String resultado = "" + operacion;
  275. return convertirDecimalAhexadecimal(resultado);
  276. }
  277.  
  278. /**
  279. *
  280. * @param primerOperando
  281. * @param segundoOperando
  282. * @param baseOperacion
  283. * @return
  284. */
  285. private static String Multiplicar(String primerOperando,
  286. String segundoOperando, int baseOperacion)
  287. {
  288.  
  289. String retorno = "Resultado Multiplicacion: ";
  290.  
  291. switch (baseOperacion)
  292. {
  293. // Binario
  294. case 1:
  295. retorno += MultiplicarBinarios(primerOperando, segundoOperando);
  296. break;
  297. // Octal
  298. case 2:
  299. retorno += MultiplicarOctal(primerOperando, segundoOperando);
  300. break;
  301.  
  302. // Decimal
  303. case 3:
  304. retorno += MultiplicarDecimal(primerOperando, segundoOperando);
  305. break;
  306.  
  307. // Hexadecimal
  308. case 4:
  309. retorno += MultiplicarHexadecimal(primerOperando, segundoOperando);
  310. break;
  311. }
  312.  
  313. return retorno;
  314. }
  315.  
  316. // Multiplicar Binarios
  317. private static String MultiplicarBinarios(String primerOperando,
  318. String segundoOperando)
  319. {
  320. String primerBinario = convertirBinarioADecimal(primerOperando);
  321. String segundoBinario = convertirBinarioADecimal(segundoOperando);
  322. int primero = Integer.parseInt(primerBinario);
  323. int segundo = Integer.parseInt(segundoBinario);
  324. int operacion = primero * segundo;
  325. String resultado = "" + operacion;
  326. return convertirDecimalABinario(resultado);
  327. }
  328.  
  329. // Multiplicar Octal
  330. private static String MultiplicarOctal(String primerOperando,
  331. String segundoOperando)
  332. {
  333. String primerOctal = convertirOctalADecimal(primerOperando);
  334. String segundoOctal = convertirOctalADecimal(segundoOperando);
  335. int primero = Integer.parseInt(primerOctal);
  336. int segundo = Integer.parseInt(segundoOctal);
  337. int operacion = primero * segundo;
  338. String resultado = "" + operacion;
  339. return convertirDecimalAoctal(resultado);
  340. }
  341.  
  342. // Multiplicar Decimal
  343. private static String MultiplicarDecimal(String primerOperando,
  344. String segundoOperando)
  345. {
  346. int primero = Integer.parseInt(primerOperando);
  347. int segundo = Integer.parseInt(segundoOperando);
  348. int operacion = primero * segundo;
  349. String resultado = "" + operacion;
  350. return resultado;
  351. }
  352.  
  353. // Multiplicar hexadecimal
  354. private static String MultiplicarHexadecimal(String primerOperando,
  355. String segundoOperando)
  356. {
  357. String primerOctal = convertirHexadecimalADecimal(primerOperando);
  358. String segundoOctal = convertirHexadecimalADecimal(segundoOperando);
  359. int primero = Integer.parseInt(primerOctal);
  360. int segundo = Integer.parseInt(segundoOctal);
  361. int operacion = primero * segundo;
  362. String resultado = "" + operacion;
  363. return convertirDecimalAhexadecimal(resultado);
  364. }
  365.  
  366. /**
  367. * toma los datos a operar
  368. *
  369. */
  370. public static String[] ingresarDatosOperacion()
  371. {
  372. String primerDato = JOptionPane.showInputDialog("Primera Base:");
  373. String segundoDato = JOptionPane.showInputDialog("Segunda Base:");
  374.  
  375. return new String[] { primerDato, segundoDato };
  376. }
  377.  
  378. /**
  379. * Metodo que convierte un numero de una base a otra.
  380. *
  381. * @param baseOrigen
  382. * Base en la que esta escrito el numero que se desea convertir.
  383. * @param baseDestino
  384. * Base a la que se desea convertir el metodo.
  385. * @param numeroIngresado
  386. * Numero que se desea convertir.
  387. * @return El numero convertido a la base destino.
  388. */
  389. public static String convertirNumeroBase(int baseOrigen, int baseDestino,
  390. String numeroIngresado)
  391. {
  392.  
  393. String retorno = "Resultado: ";
  394.  
  395. switch (baseOrigen)
  396. {
  397. // Binario
  398. case 1:
  399.  
  400. switch (baseDestino)
  401. {
  402. // Octal
  403. case 2:
  404. retorno += convertirBinarioAOctal(numeroIngresado);
  405. break;
  406.  
  407. // Decimal
  408. case 3:
  409. retorno += convertirBinarioADecimal(numeroIngresado);
  410. break;
  411.  
  412. // Hexadecimal
  413. case 4:
  414. retorno += convertirBinarioAHexadecimal(numeroIngresado);
  415. break;
  416. }
  417.  
  418. break;
  419.  
  420. // Octal
  421. case 2:
  422. switch (baseDestino)
  423. {
  424. // Binario
  425. case 2:
  426. retorno += convertirOctalABinario(numeroIngresado);
  427. break;
  428.  
  429. // Decimal
  430. case 3:
  431. retorno += convertirOctalADecimal(numeroIngresado);
  432. break;
  433.  
  434. // Hexadecimal
  435. case 4:
  436. retorno += convertirOctalAhexdecimal(numeroIngresado);
  437. break;
  438. }
  439. break;
  440.  
  441. // Decimal
  442. case 3:
  443. switch (baseDestino)
  444. {
  445. // Binario
  446. case 2:
  447. retorno += convertirDecimalABinario(numeroIngresado);
  448. break;
  449. // octal
  450. case 3:
  451. retorno += convertirDecimalAoctal(numeroIngresado);
  452. break;
  453.  
  454. // hexadecimal
  455. case 4:
  456. retorno += convertirDecimalAhexadecimal(numeroIngresado);
  457. break;
  458. }
  459. break;
  460.  
  461. // Hexadecimal
  462. case 4:
  463. switch (baseDestino)
  464. {
  465. // Binario
  466. case 2:
  467. retorno += convertirHexadecimalABinario(numeroIngresado);
  468. break;
  469. // octal
  470. case 3:
  471. retorno += convertirHexadecimalAOctal(numeroIngresado);
  472. break;
  473.  
  474. // decimal
  475. case 4:
  476. retorno += convertirHexadecimalADecimal(numeroIngresado);
  477. break;
  478. }
  479. break;
  480. }
  481.  
  482. System.out.println("baseOrigen " + baseOrigen + " baseDestino "
  483. + baseDestino + " numeroIngresado " + numeroIngresado);
  484. return retorno;
  485. }
  486.  
  487. /**
  488. * Pasa un numero de decimal a hexadecimal.
  489. *
  490. * @param numeroIngresado
  491. * Numero a convertir
  492. *
  493. */
  494. public static String convertirDecimalAhexadecimal(String bas)
  495. {
  496. int decimal = Integer.parseInt(bas);
  497. String digits = "0123456789ABCDEF";
  498. if (decimal == 0)
  499. return "0";
  500. String hexde = "";
  501. while (decimal > 0) {
  502. int mod = decimal % 16; // Dígito de la derecha
  503. hexde = digits.charAt(mod) + hexde; // Concatenación de cadenas
  504. decimal = decimal / 16;
  505. }
  506. return hexde;
  507. }
  508.  
  509. /**
  510. *
  511. * Pasa un numero de decimal a Octal.
  512. *
  513. * @param numeroIngresado
  514. * Numero a convertir
  515. */
  516. public static String convertirDecimalAoctal(String base)
  517. {
  518. int inicio = Integer.parseInt(base);
  519. String acomular = "";
  520. if (inicio <= 8)
  521. {
  522. acomular += inicio;
  523. } else {
  524. int div1 = inicio / 8;
  525. int div2 = div1 / 8;
  526. int div3 = div2 / 8;
  527. int div4 = div3 / 8;
  528. int div5 = div4 / 8;
  529. int div6 = div5 / 8;
  530. int div7 = div6 / 8;
  531. int div8 = div7 / 8;
  532. int div9 = div8 / 8;
  533. int[] arreglo = new int[10];
  534. arreglo[0] = inicio % 8;
  535. arreglo[1] = div1 % 8;
  536. arreglo[2] = div2 % 8;
  537. arreglo[3] = div3 % 8;
  538. arreglo[4] = div4 % 8;
  539. arreglo[5] = div5 % 8;
  540. arreglo[6] = div6 % 8;
  541. arreglo[7] = div7 % 8;
  542. arreglo[8] = div8 % 8;
  543. arreglo[9] = div9 % 8;
  544. for (int i = arreglo.length - 1; i >= 0; i--)
  545. {
  546. if (arreglo[i] != 0)
  547. {
  548. acomular += arreglo[i];
  549. }
  550. }
  551.  
  552. }
  553. return acomular;
  554. }
  555.  
  556. /**
  557. *
  558. * Pasa un numero de decimal a Binario.
  559. *
  560. * @param numeroIngresado
  561. * Numero a convertir
  562. */
  563. public static String convertirDecimalABinario(String base)
  564. {
  565. int baseinte = Integer.parseInt(base);
  566. String binario = "";
  567. while (baseinte > 0)
  568. {
  569. binario = baseinte % 2 + binario;
  570. baseinte /= 2;
  571. }
  572. return binario;
  573. }
  574.  
  575. /**
  576. *
  577. * Pasa un numero de hexadecimal A Decimal.
  578. *
  579. * @param numeroIngresado
  580. * Numero a convertir
  581. */
  582. public static String convertirHexadecimalADecimal(String base)
  583. {
  584. String digitos = "0123456789ABCDEF";
  585. String decimal = "";
  586. base = base.toUpperCase();
  587. int decimalx = 0;
  588. for (int i = 0; i < base.length(); i++)
  589. {
  590. char c = base.charAt(i);
  591. int d = digitos.indexOf(c);
  592. decimalx = 16 * decimalx + d;
  593. }
  594. decimal += decimalx;
  595. return decimal;
  596. }
  597.  
  598. /**
  599. * Pasa un numero de Octal A Decimal.
  600. *
  601. * @param numeroIngresado
  602. * Numero a convertir
  603. */
  604. public static String convertirOctalADecimal(String base)
  605. {
  606. String cadenaInver = "";
  607. int b = 0;
  608. int c = 0;
  609. String decimal = "";
  610. for (int i = base.length() - 1; i >= 0; i--)
  611. {
  612. cadenaInver += "" + base.charAt(i);
  613. }
  614.  
  615. for (int i = 0; i < cadenaInver.length(); i++)
  616. {
  617. String convertir = "" + cadenaInver.charAt(i);
  618. b = Integer.parseInt(convertir);
  619. c += (b * Math.pow(8, i));
  620. }
  621. decimal += c;
  622. return decimal;
  623. }
  624.  
  625. /**
  626. * Pasa un numero de Binario A Octal.
  627. *
  628. * @param numeroIngresado
  629. * Numero a convertir
  630. */
  631. public static String convertirBinarioAOctal(String base)
  632. {
  633. String a = convertirBinarioADecimal(base);
  634. String octal = convertirDecimalAoctal(a);
  635. return octal;
  636.  
  637. }
  638.  
  639. /**
  640. * Pasa un numero de Binario A hexadecimal.
  641. *
  642. * @param numeroIngresado
  643. * Numero a convertir
  644. */
  645. public static String convertirBinarioAHexadecimal(String base)
  646. {
  647. String a = convertirBinarioADecimal(base);
  648. String hexadecimal = convertirDecimalAhexadecimal(a);
  649. return hexadecimal;
  650.  
  651. }
  652.  
  653. /**
  654. * Pasa un numero de Binario A hexadecimal.
  655. *
  656. * @param numeroIngresado
  657. * Numero a convertir
  658. */
  659. public static String convertirOctalAhexdecimal(String base)
  660. {
  661. String a = convertirOctalADecimal(base);
  662. String hexadecimal = convertirDecimalAhexadecimal(a);
  663. return hexadecimal;
  664.  
  665. }
  666.  
  667. /**
  668. * Pasa un numero de Octal A Binario.
  669. *
  670. * @param numeroIngresado
  671. * Numero a convertir
  672. */
  673. public static String convertirOctalABinario(String base)
  674. {
  675. String a = convertirOctalADecimal(base);
  676. String bianrio = convertirDecimalABinario(a);
  677. return bianrio;
  678. }
  679.  
  680. /**
  681. * Pasa un numero de Hexadecimal A Binario
  682. *
  683. * @param numeroIngresado
  684. * Numero a convertir
  685. */
  686. public static String convertirHexadecimalABinario(String base)
  687. {
  688. String a = convertirHexadecimalADecimal(base);
  689. String binario = convertirDecimalABinario(a);
  690. return binario;
  691.  
  692. }
  693.  
  694. /**
  695. * Pasa un numero de Hexadecimal A Octal
  696. *
  697. * @param numeroIngresado
  698. * Numero a convertir
  699. */
  700. public static String convertirHexadecimalAOctal(String base)
  701. {
  702. String a = convertirHexadecimalADecimal(base);
  703. String octal = convertirDecimalAoctal(a);
  704. return octal;
  705.  
  706. }
  707.  
  708. /**
  709. * Pasa un numero de Binario A Decimal.
  710. *
  711. * @param numeroIngresado
  712. * Numero a convertir
  713. */
  714. public static String convertirBinarioADecimal(String base)
  715. {
  716.  
  717. String cadenaInver = "";
  718. int b = 0;
  719. int c = 0;
  720. String resulString = "";
  721. for (int i = base.length() - 1; i >= 0; i--)
  722. {
  723. cadenaInver += "" + base.charAt(i);
  724. }
  725. double[] arreglo;
  726. for (int i = 0; i <= cadenaInver.length(); i++)
  727. {
  728. arreglo = new double[99];
  729. arreglo[i] = (Math.pow(2, i));
  730.  
  731. for (int m = 0; m < cadenaInver.length(); m++)
  732. {
  733. String convertir = "" + cadenaInver.charAt(m);
  734. b = Integer.parseInt(convertir);
  735. c += b * arreglo[m];
  736. }
  737. }
  738. resulString += c;
  739. return resulString;
  740. }
  741.  
  742. /**
  743. * Menu para seleccionar base en la operación de conversión.
  744. *
  745. * @param seleccionado
  746. * Numero seleccionado anteriormente, si se le pasa un -1 se
  747. * mostre todas las opciones.
  748. *
  749. * @return La base seleccionada por el usuario.
  750. */
  751. public static int menuBase(int seleccionado)
  752. {
  753.  
  754. int baseSeleccionada = -1;
  755. if (seleccionado == -1)
  756. {
  757. // 1 binario, 2 octal, 3 decimal, 4 hexadecimal.
  758.  
  759. baseSeleccionada = Integer.parseInt(JOptionPane.showInputDialog("Ingrese una Base \n"
  760. + "1 - Binario \n"
  761. + "2 - Octal \n" + "3 - Decimal \n"
  762. + "4 - Hexadecimal"));
  763. } else
  764. {
  765.  
  766. String opcionBinario = " Binario \n";
  767. String opcionOctal = " Octal \n";
  768. String opcionDecimal = " Decimal \n";
  769. String opcionHexadecimal = " Hexadecimal";
  770. String opcionesSeleccionables = "";
  771. int contador =2;
  772. if (seleccionado != 1)
  773. opcionesSeleccionables +=contador++ +opcionBinario;
  774. if (seleccionado != 2)
  775. opcionesSeleccionables +=contador++ + opcionOctal;
  776. if (seleccionado != 3)
  777. opcionesSeleccionables +=contador++ + opcionDecimal;
  778. if (seleccionado != 4)
  779. opcionesSeleccionables +=contador++ + opcionHexadecimal;
  780.  
  781. baseSeleccionada = Integer.parseInt(JOptionPane.showInputDialog("Ingrese una Base \n"
  782. + opcionesSeleccionables));
  783. }
  784.  
  785. if (baseSeleccionada <= 0 || baseSeleccionada > 4)
  786. {
  787. JOptionPane.showMessageDialog(null, "Rango Invalido", "Error!",
  788. JOptionPane.ERROR_MESSAGE);
  789. }
  790.  
  791. return baseSeleccionada;
  792. }
  793.  
  794. public static String ingresarNumero()
  795. {
  796. return JOptionPane.showInputDialog("Ingrese el numero en la base origen");
  797. }
  798.  
  799. }
Add Comment
Please, Sign In to add comment