desarrollar un ejercicio con clases

Iniciado por jugran28, 11 Junio 2007, 01:49 AM

0 Miembros y 1 Visitante están viendo este tema.

jugran28

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;
       
       
    }
   
}

Crack_X

Usa la etiqueta codigo la proxima vez por favor.

Te falto un ; aqui:

public int CalculoIntersecion()throws IOException{
        clase3 OBB = new clase3();
Shit loads of money spend to show us wrong from right. Say no to war


Yasser Has Things To Say
WarZone

jugran28

ya lo hice amigos gracias por su apoyo me salio de maravilla tuve que coregir varias cosas