The document describes a Java program that defines classes for converting numbers between binary, hexadecimal, and octal representations. The BaseNumerica class contains methods to convert an integer to its binary, hexadecimal, and octal string representations. The interfaz class creates a GUI with labels, buttons, and fields to accept a number from the user and display its converted representations. When the conversion buttons are clicked, the appropriate method from BaseNumerica is called to perform the conversion.
Risk Assessment For Installation of Drainage Pipes.pdf
Convert Numbers Binary, Hexadecimal, Octal
1. /*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package basenumerica;
/**
*
* @author jorge andres
*/
public class BaseNumerica {
public String intBin(int n){
return Integer.toBinaryString(n);
}
public String intHex(int n){
return Integer.toHexString(n);
}
public String intOct(int n){
return Integer.toOctalString(n);
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
new interfaz().setVisible(true);
}
}
2. /*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package basenumerica;
/**
*
* @author jorge andres
*/
public class interfaz extends javax.swing.JFrame {
/**
* Creates new form interfaz
*/
public interfaz() {
initComponents();
}
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
txtnumero = new javax.swing.JTextField();
calcular = new javax.swing.JButton();
lblBin = new javax.swing.JLabel();
calcula = new javax.swing.JButton();
calcul = new javax.swing.JButton();
lblOct = new javax.swing.JLabel();
lblHex = new javax.swing.JLabel();
jLabel1.setText("jLabel1");
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel2.setText("Ingrece el numero a convertir");
calcular.setText("binario");
calcular.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent
evt) {
calcularActionPerformed(evt);
}
});
calcula.setText("octagonal");
calcula.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent
evt) {
calculaActionPerformed(evt);