|
Mostrar Mensajes
|
Páginas: [1] 2
|
2
|
Programación / .NET (C#, VB.NET, ASP) / migrar programa c# de console a entorno windows
|
en: 29 Noviembre 2007, 13:29 pm
|
hola amigos de este prestigioso foro tengo un programa diseñado en c# es sobre un aray unidimensional es al ingresar su longitud del aray luego ingresas datos segun su longitud ingresado... el detalle es que me pidieron en la universidad migrar el programa que esta diseñado en modo console a entorno windows es decir en un textbox ingrese su longitud y donde podria ingresar los datos en otro textbox, segun la longitud ingresado aca dejo el codigo en console el programa esta diseñado en c# using System; using System.Collections.Generic; using System.Text;
namespace ññdelegate { public delegate void impresion(int a); class demo { public void impresion1(int a) { for(int i=0; i< a; i++ ) { Console.WriteLine(i); } Console.ReadLine(); }
}
class Program { static void Main(string[] args) { demo ok1 = new demo(); //impresion ok = ok1.impresion1; impresion ok = new impresion(ok1.impresion1); ok(10); } } } aca estuve diseñando en entorno windows pero tengo dudas como hacerlo ayudenme por favor por decir en un texbox ingrese su longitud ahora segun ello deberia ingresar datos nop se si hacerlo en un textbox o en otra herramienta y que el resulyado em salga en label o con un mshbox ayudenme si por favor
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;
namespace areglo { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button2_Click(object sender, EventArgs e) { this.Close(); }
private void btnProcesar_Click(object sender, EventArgs e) { int a;
txtLongitud.Text=a string[] op = new string[a]; for (int i = 0; i < op.Length; i++) { Console.WriteLine("ingrese datos"); op = Console.ReadLine(); } }
|
|
|
4
|
Programación / .NET (C#, VB.NET, ASP) / ayuda a desarollar program en visual basic.net
|
en: 13 Noviembre 2007, 19:13 pm
|
hola amigos tengo un problema al desarollar un programita en visual basic.net el detalle es que quiero validar dentro de un cuadro de texto que solo se ingrese hasta 30 , pero cuando pongo en actualizar me debe borar todos los datos en cuadro de texto ponerse en blanco pero me da error solo D = CInt(txtDias.Text) r// aca me da eror que el tipo de dato no puede convertir que podria cambiar alguien si me puede ayudar por favor
'metodo actualizar Public Sub limpiar() txtNOMBre.Text = "" txtDias.Text = "" ComboBox1.Text = "" End Sub 'metodo validacion para ingresar solo hasta 30 dias Public Sub solod() Dim soloD As Integer soloD = CInt(txtDias.Text) // aca me da eror que el tipo de dato no puede convertir[/u] If soloD > 30 Then MsgBox("Ingresar Solo Hasta 30 x Dias Trabajadas", MsgBoxStyle.Information, "Advertencia") End If End Sub 'llamando metodo actualzar Private Sub btnActual_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnActual.Click Me.limpiar()
End Sub End Class
|
|
|
5
|
Programación / .NET (C#, VB.NET, ASP) / duda con un programa en c#
|
en: 13 Noviembre 2007, 18:27 pm
|
hola por la presente para solitarles su ayuda tengo un programa echo en c#es sobre la suma de areglos bidimencional el problema que tengo es no se como declarar dentro de una clase un areglo bidimensional esto por su pùesto dentro de un metodomi declaracion esta echo asi : public int sumabidi1(int[,] suma = new int[3, 3]) esto me sale error haber si alguien me ayuda aca pues mi codigo fuente... haber por favor quiero sus opiniones saludos // clase suma namespace suma { class sumabidi
{ public int sumabidi1(int[,] suma = new int[3, 3]) { int[,] A = new int[3,3]; int[,] B = new int[3,3]; for (int i = 0; i <3; i++) { for (int j = 0; j <3; j++) { suma[i,j] = A[i,j] + B[i,j]; Console.WriteLine("Resultado suma ["+i+"]["+j+"] ="+suma[i,j]); Console.ReadLine(); } } } } } // esto es la clase principal using System; using System.Collections.Generic; using System.Text;
namespace suma { class Program { static void Main(string[] args) { sumabidi ok = new sumabidi(); int[,] A = new int[3,3]; int[,] B = new int[3,3]; int x, y; for (int i = 0; i <3; i++) { for (int j = 0; j <3; j++) { Console.WriteLine("ingrese el valor en A[{0}] ",A[i,j]); x = Int32.Parse(Console.ReadLine()); A[i,j] = x; } } for (int i = 0; i <3; i++) { for (int j = 0; j <3; j++) { Console.WriteLine("ingrese el valor en B[{0}] ", B[i,j]); y = Int32.Parse(Console.ReadLine()); B[i,j] = y; } } } } }
|
|
|
6
|
Programación / .NET (C#, VB.NET, ASP) / ayuda a resolver dos ejercicios en c#
|
en: 7 Agosto 2007, 16:22 pm
|
1.- Buenas amigos haber si me echan una mano con este programa que me permita ingresar en un aray bidimensional donde tengo que mandar mensaje si ingrese numeros enteros o datos de caracter estuve haciendo mi programa pero en la condicion if no veo como declarar la condicion que sea numerico o caracter
using System; using System.Collections.Generic; using System.Text;
namespace pronumeristring { class Program { static void Main(string[] args) { int op, op1; string z, y, ok1; Console.WriteLine("Ingrese filas"); op = int.Parse(Console.ReadLine()); Console.WriteLine("Ingrese filas"); op1 = int.Parse(Console.ReadLine()); string[,] ok = new string[op, op1];
for (int i = 0; i < op; i++) { for (int j = 0; j < op1; j++) { Console.WriteLine("Ingrese datos"); ok[i, j] = Console.ReadLine();
if (ok[i,j]!=int.Parse(Console.ReadLine()))// aca me falta dar la condicion Console.WriteLine("Ud Ingreso Datos Numericos{0}",ok[i,j]); else Console.WriteLine("Ud Ingreso Datos Caracter{0}",ok[i,j]); Console.ReadLine(); } } } } }
2.- Este programa permite sumar un aray bimensioanle y que asu vez la suma guarde en un archivo dentro de disco duro aca les paso mi codigo fuente lo que no se es como hacer para guardar en el disco duro la operacion que sale de la suma amespace suma { class Program { static void Main(string[] args) { float[][] A = new float[][]; float[][] B = new float[][]; float[][] suma = new float[][]; int x, y; for (int i = 0; i <5; i++) { for (int j = 0; j <5; j++) { Console.WriteLine("ingrese el valor en A[{0}] ", A[j]); x = Int32.Parse(Console.ReadLine()); A[j] = x; } } for (int i = 0; i <3; i++) { for (int j = 0; j <3; j++) { Console.WriteLine("ingrese el valor en B[{0}] ", B[j]); y = Int32.Parse(Console.ReadLine()); B[j] = y; } } for (int i = 0; i <3; i++) { for (int j = 0; j <3; j++) { suma[ j] = A[ j] + B[j]; Console.WriteLine("Resultado suma ["+i+"]["+j+"] ="+suma[j]); Console.ReadLine(); } } }
static void graba(int[] suma) { int i; StreamWriter archivo = new StreamWriter(FILE_NAME); for (i = 0; i < suma.Length; i++) { archivo.WriteLine(ingreso); } Console.Write("LOS ELEMENTO DEL ARRAY SE GRABARAON EN EL ARCHIVO"); archivo.Close(); }
} }
espero sus grata respuesta
|
|
|
7
|
Programación / Java / ayuda a resolrver ejercicios sobre formularios
|
en: 24 Julio 2007, 00:35 am
|
Por la presente para pedirles ayuda se trata de un pequeño programa utlilizando el componente java.swing formularios, lo que deseo es añadir dos botones mas un boton de guardar y otro boton de leer la idea es que cuando presiono el boton de guardar me guarde todo lo que ingreso en este pequeño programa en un directorio del disco duro luego cuando presion el boton de leer que me abre el archivo guardado en el disco duro aca pongo asu disposicion el codigo fuente por favor nesecito sus ayuda aresolever y agregar codigo fuente en el boton guardar y leer
//Programa que permite el ingreso de datos luego visualiza en un textArea package Swing; import javax.swing.JOptionPane;
public class IngresoDatos extends javax.swing.JFrame { public IngresoDatos() { initComponents(); } // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { grupSexo = new javax.swing.ButtonGroup(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); txtApePat = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); txtApeMat = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtNombres = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); cboEstCivil = new javax.swing.JComboBox(); jPanel2 = new javax.swing.JPanel(); optSexM = new javax.swing.JRadioButton(); optSexF = new javax.swing.JRadioButton(); btGuardar = new javax.swing.JButton(); btnSair = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); txtLista = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Formulario de Ingreso de Datos"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowOpened(java.awt.event.WindowEvent evt) { formWindowOpened(evt); } });
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Datos Personales")); jLabel1.setText("Apeliido Paterno:");
jLabel2.setText("Apellido Materno:");
jLabel3.setText("Nombres:");
jLabel4.setText("Estado Civil FGFDG FDFGFDGD :"); jLabel4.getAccessibleContext().setAccessibleName("Estado Civil FGJDFGFDG FDG\u00d1LDFGMDF:");
cboEstCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jPanel2.setBackground(new java.awt.Color(255, 255, 255)); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Sexo")); grupSexo.add(optSexM); optSexM.setText("Masculino"); optSexM.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); optSexM.setMargin(new java.awt.Insets(0, 0, 0, 0));
grupSexo.add(optSexF); optSexF.setText("Femenino"); optSexF.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); optSexF.setMargin(new java.awt.Insets(0, 0, 0, 0));
org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(32, 32, 32) .add(optSexM) .add(32, 32, 32) .add(optSexF) .addContainerGap(57, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2Layout.createSequentialGroup() .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(optSexM) .add(optSexF)) .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );
org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .add(71, 71, 71) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) .add(jLabel3) .add(jLabel1) .add(jLabel2)) .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jPanel1Layout.createSequentialGroup() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(txtApeMat, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) .add(txtNombres, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 220, Short.MAX_VALUE) .add(jPanel1Layout.createSequentialGroup() .add(cboEstCivil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 174, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 46, Short.MAX_VALUE)) .add(txtApePat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 220, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(43, 43, 43))) .add(24, 24, 24)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel1Layout.createSequentialGroup() .addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(jLabel1) .add(txtApePat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false) .add(jLabel2) .add(txtApeMat, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false) .add(jLabel3) .add(txtNombres, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE, false) .add(cboEstCivil, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(jLabel4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 22, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 45, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .add(52, 52, 52)) );
btGuardar.setText("Guardar"); btGuardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btGuardarActionPerformed(evt); } });
btnSair.setLabel("Salir"); btnSair.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSairActionPerformed(evt); } });
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Listado")); txtLista.setColumns(20); txtLista.setRows(5);
org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .addContainerGap() .add(txtLista, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 435, Short.MAX_VALUE) .addContainerGap()) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(jPanel3Layout.createSequentialGroup() .addContainerGap() .add(txtLista, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addContainerGap(36, Short.MAX_VALUE)) );
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .add(btGuardar) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 347, Short.MAX_VALUE) .add(btnSair)) .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(layout.createSequentialGroup() .addContainerGap() .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 241, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(btGuardar) .add(btnSair)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents
private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed if(evt.equals(btnSair)) System.exit(0); }//GEN-LAST:event_btnSairActionPerformed
private void btGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btGuardarActionPerformed //validando entradas String data=""; if (txtApePat.getText().equals("")){ JOptionPane.showMessageDialog(null,"Ingrese Apellido Paterno"); return; } if (txtApeMat.getText().equals("")){ JOptionPane.showMessageDialog(null,"Ingrese Apellido Materno"); return; } if (txtNombres.getText().equals("")){ JOptionPane.showMessageDialog(null,"Ingrese Nombres"); return; } //grabamos data = txtLista.getText() + txtApePat.getText() + " " + txtApeMat.getText() + " "+txtNombres.getText() + " " + cboEstCivil.getSelectedItem(); if ( optSexM.isSelected() ) data += " Masculino"; else data += " Femenino"; txtLista.setText(data+"\n"); }//GEN-LAST:event_btGuardarActionPerformed
private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened cboEstCivil.removeAllItems(); cboEstCivil.addItem("Soltero"); cboEstCivil.addItem("Casado"); cboEstCivil.addItem("Divorciado"); cboEstCivil.addItem("Viudo"); }//GEN-LAST:event_formWindowOpened public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new IngresoDatos().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btGuardar; private javax.swing.JButton btnSair; private javax.swing.JComboBox cboEstCivil; private javax.swing.ButtonGroup grupSexo; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JRadioButton optSexF; private javax.swing.JRadioButton optSexM; private javax.swing.JTextField txtApeMat; private javax.swing.JTextField txtApePat; private javax.swing.JTextArea txtLista; private javax.swing.JTextField txtNombres; // End of variables declaration//GEN-END:variables }
|
|
|
9
|
Programación / Java / desarrollar un ejercicio con clases
|
en: 11 Junio 2007, 01:49 am
|
hola amigos me piden un programa en java utilizando clases pero el<programa tiene que sacar la union intersecion diferencia de un connjunto ay b el< detalle es que no se muchop utilizar clases haber si alguin me apoya aca lo estuve haciendo pero me sale< algunos erros haber si me apoyan por favor. al ejectutar el programa me da este error
init: deps-jar: Compiling 3 source files to C:\Documents and Settings\USER.TOSHIBA\proclaconjuntos\build\classes C:\Documents and Settings\USER.TOSHIBA\proclaconjuntos\src\proclaconjuntos\clase2.java:32: ';' expected for (int i=0; i<5; i++) 1 error BUILD FAILED (total time: 1 second) haber si por favor me podrian ayudar a encontrar el error
les agradecere muy infinitamente
package proclaconjuntos; import java.io.*;
public class Main { public static void main(String[] args)throws IOException { int C; do{ System.out.println("- - - -Programa que Calcula Conjuntos Union Interseccion y Diferencia- - - -"); System.out.println(" 1 : Calculo Union Conjunto A y B"); System.out.println(" 2 : Calculo Intersecion Conjunto A y B"); System.out.println(" 3 : Calculo de la Direnecia Conjutn A y B"); BufferedReader dato1 = new BufferedReader(new InputStreamReader(System.in)); String d1 = dato1.readLine(); int OP = Integer.parseInt(d1); switch(OP) { case 1: { clase2 OB1 = new clase2(); System.out.println("---Union A y B---"); System.out.println(OB1.CalculoUnion()); break; } case 2: { clase2 OB2 = new clase2(); System.out.println("---Interseccion A y B---"); System.out.println(OB2.CalculoIntersecion()); break; } case 3: { clase2 OB3 = new clase2(); System.out.println("---Diferencia A y B---"); System.out.println(OB3.CalculoDiferencia()); break; } default: { System.out.println("Opcion no valida"); } } System.out.println("Para Salir Ingrese el Valor Cero"); BufferedReader dato10 = new BufferedReader(new InputStreamReader(System.in)); String c1 = dato10.readLine(); int Z = Integer.parseInt(c1); C=Z; }while(C!=0); } }
//Clase que sealiza los calculos package proclaconjuntos;
import java.io.*; public class clase2 { public clase2() { int A[]=new int [5]; int B[]=new int [5]; int C[]=new int [100]; } public int CalculoUnion()throws IOException{ clase3 OBA = new clase3(); for (int i=0;i<5;i++) System.out.println(" Ingrese Valores Conjunto A["+i+"] = "); B = OBA.IngDato1(); for (int i=0;i<5;i++) System.out.println("Ingrese Valores Conjunto B["+i+"] = "); A = OBA.IngDato2(); System.out.println("Union A y B = "); for(int i=0, cont=0; i<5; i++) for(int j=0; j<5; j++) if(A==B[j]) C[cont++]=A; System.out.println("La union de A y B es:"); for(int i=0; i<10; i++) System.out.print(C!=0 ? C : ""); return 0; } public int CalculoIntersecion()throws IOException{ clase3 OBB = new clase3() for (int i=0; i<5; i++) System.out.println("Ingrese Valores Conjunto A["+i+"] = "); B = OBB.IngDato1(); for (int i=O;i<5;i++) System.out.println("Ingrese Valores Conjunto B["+i+"] = "); A = OBB.IngDato2(); System.out.println(" Interseccion de A y B = "); for(int i=0; i<5; i++) C=A; for(int i=0, cont=5; i<5; i++) { C[cont++]=B; for(int j=0; j<5; j++) if(C[j]==B)--cont; } System.out.println("La interseccion de A y B es:"); for(int i=0; i<10; i++) System.out.print(C!=0 ? C : ""); return 0; } public int CalculoDiferencia()throws IOException{ clase3 OBC = new clase3(); for (int i=0;i<5;i++) System.out.println("Ingrese Valores Conjunto A["+i+"] = "); B = OBC.IngDato1(); for (int i=O;i<5;i++) System.out.println("Ingrese Valores Conjunto B["+i+"] = "); A = OBC.IngDato2(); System.out.println(" Diferencia de A y B = "); for(int i=0; i<5; i++) C=A; System.out.println("La interseccion de A y B es:"); for(int i=0; i<10; i++) System.out.print(C!=0 ? C : ""); return 0; } }
package proclaconjuntos; import java.io.*; public class clase3 { public clase3() { } public double IngDato1()throws IOException{ BufferedReader dato1 = new BufferedReader(new InputStreamReader(System.in)); double X = Double.valueOf(dato1.readLine().trim()).doubleValue(); return X; } public double IngDato2()throws IOException{ BufferedReader dato1 = new BufferedReader(new InputStreamReader(System.in)); double Y = Double.valueOf(dato1.readLine().trim()).doubleValue(); return Y; } }
|
|
|
10
|
Programación / Ejercicios / ayuda a desarrollar programa
|
en: 1 Junio 2007, 01:15 am
|
/ programa que calcula el area perimetro de un rectnagulo triangulo y circulo usando metodos y debe ser intercativo para salir del programa debe escirbir la letra N de preferencia aca solo me falta que cuando presiono la letra N me tiene que salir saludos package proareaperec; import java.io.*; public class Main { static double TrianguloP(double base, double hal){ double P,Hipo; Hipo = Math.sqrt(Math.pow(base,2)+Math.pow(hal,2)); P=base+hal+Hipo; return P; } static double RectanguloP(double base, double hal){ double P; P=base*2+hal*2; return P; } static double CirculoP(double r, double PI=3.1416){ double A, double PI=3.1416, double r; P=(PI*r*r); return P; } static double TrianguloA(double base, double hal){ double A; A=(base*hal)/2; return A; } static double RectanguloA(double base, double hal){ double A; A=base*hal; return A; } static double CirculoAre(double r, double PI=3.1416){ double A, double PI=3.1416, double r; A=(PI*r*r); return A; } public static void main(String[] args)throws IOException { System.out.println("Ingrese un numero "); System.out.println("1. Calcular el Perimetro del Triangulo "); System.out.println("2. Calcular el Perimetro del Rectangulo"); System.out.println("3. Calcular el Area del Rectangulo"); System.out.println("4. Calcular el Area del Rectangulo"); System.out.println("5. Calcular el Perimetro del Circulo"); System.out.println("6. Calcular el Perimetro del Circulo"); System.out.println("N. Salir del programa"); // aca me falta programar al presionar la letra N debe de salir del programa System.out.println("Ingrese un numero = "); BufferedReader dato1 = new BufferedReader(new InputStreamReader(System.in)); int Z = Integer.valueOf(dato1.readLine().trim()).intValue(); switch(Z) { case 1: { System.out.println("Ingrese la Base = "); BufferedReader dato2 = new BufferedReader(new InputStreamReader(System.in)); double X = Double.valueOf(dato2.readLine().trim()).doubleValue(); System.out.println("Ingrese la Altura = "); BufferedReader dato3 = new BufferedReader(new InputStreamReader(System.in)); double Y = Double.valueOf(dato3.readLine().trim()).doubleValue(); System.out.println("Perimetro del Triangulo ="); System.out.println(TrianguloP(X,Y)); System.out.println("Area del Triangulo ="); System.out.println(TrianguloA(X,Y)); break; } case 2: { System.out.println("Ingrese la Base = "); BufferedReader dato2 = new BufferedReader(new InputStreamReader(System.in)); double X = Double.valueOf(dato2.readLine().trim()).doubleValue(); System.out.println("Ingrese la Altura = "); BufferedReader dato3 = new BufferedReader(new InputStreamReader(System.in)); double Y = Double.valueOf(dato3.readLine().trim()).doubleValue(); System.out.println("Perimetro del Reactangulo ="); System.out.println(RectanguloP(X,Y)); System.out.println("Area del Reactangulo ="); System.out.println(RectanguloA(X,Y)); break; } case 3:{ System.out.println("Ingrese la Base = "); BufferedReader dato2 = new BufferedReader(new InputStreamReader(System.in)); double X = Double.valueOf(dato2.readLine().trim()).doubleValue(); System.out.println("Ingrese la Altura = "); BufferedReader dato3 = new BufferedReader(new InputStreamReader(System.in)); double Y = Double.valueOf(dato3.readLine().trim()).doubleValue(); System.out.println("Perimetro del Circulo ="); System.out.println(CirculoP(X,Y)); System.out.println("Area del Reactangulo ="); System.out.println(CirculoAre(X,Y)); break; } default:{ System.out.println("Valor no Valido"); break; } } } }
|
|
|
|
|
|
|