martes, 9 de noviembre de 2010

tipo de cambio (java netbeans)

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Alejandra
 */
import java.io.*;
public class TipoDeCambio {
    float v=0;
    float c=0;


     public TipoDeCambio(){

    }
    public TipoDeCambio(float compra , float venta , float v , float c){

        this.c=c;
        this.v=v;
    }


    public void nuevoCambio()throws IOException{
        BufferedReader n= new BufferedReader(new InputStreamReader(System.in));
        System.out.println("TIPO DE CAMBIO ");
        System.out.println("venta: ");
        v=Float.parseFloat(n.readLine());
        System.out.println("compra: ");
        c=Float.parseFloat(n.readLine());

    }
    public int ComprarDlls()throws IOException{
       BufferedReader cd= new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Cantidad a cambiar");
    float cam=Float.parseFloat(cd.readLine());
    float C=(c*cam);

    System.out.println("El total a cambiar es :"+C);
    return 0;
    }
    public int VenderDlls()throws IOException{
       BufferedReader vd= new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Cantidad a vender");
    float ven=Float.parseFloat(vd.readLine());
    float V=(v*ven);

    System.out.println("El total a vender es :"+V);
    return 0;

}
    }
------------------------------------------------------------------------------------------------

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


/**
 *
 * @author Alejandra
 */
import java.io.*;
public class Cprincipal {


    public static void main(String[] args) throws IOException{
        BufferedReader c=new BufferedReader(new InputStreamReader(System.in));
        TipoDeCambio o=new TipoDeCambio();
        int op=0;
            do{
        System.out.println("\t\tConvertir pesos a dlls y viseversa\n");
        System.out.println("\t1. Registrar tipo-cambio\n");
        System.out.println("\t2. Comprar Dlls\n");
        System.out.println("\t3. Vender Dlls\n");
        System.out.println("\t4. Salir\n");
        System.out.println("\t\tEliga su opcion:");
        op=Integer.parseInt(c.readLine());
       switch(op){
           case 1:
               o.nuevoCambio();
               break;
           case 2:
               o.ComprarDlls();
               break;
           case 3:
               o.VenderDlls();
               break;
           case 4:
               break;
       }
   }while(op!=4);
    }
}

No hay comentarios:

Publicar un comentario