Txerrinko

Decibelios

Feb 14th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.72 KB | None | 0 0
  1. package Teleco;
  2.  
  3. import java.io.IOException;
  4.  
  5. public class Decibelios {
  6.  
  7.     /**
  8.      * @param args
  9.      */
  10.    
  11.     Decibelios d;
  12.     //VARIABLES
  13.    
  14.     //watios
  15.    
  16.     //W,MW,DBW,DBM
  17.    
  18.     float W,MW, DBW,DBM,DBMV;
  19.    
  20.     //voltios
  21.    
  22.     //V,MV,DBV,DBMV
  23.    
  24.    
  25.      public float ConversorVatios (int num) throws IOException{
  26.        
  27.          System.out.println("Numero introducido "+num);
  28.          
  29.          System.out.println("MEDIDA DE CONVERSION" +
  30.                 "1. W" +
  31.                 "2.MW" +
  32.                 "3.DBW" +
  33.                 "4.DBM");
  34.          int opc1=Consola.leeInt();
  35.          
  36.          System.out.println("MEDIDA A CONVERTIR" +
  37.                  "1. W" +
  38.                   "2.MW" +
  39.                   "3.DBW" +
  40.                   "4.DBM");
  41.          int opc2=Consola.leeInt();
  42.          
  43.      while (opc1!=1 || opc1!=2 || opc1!=3 || opc1!=4 || opc1!=1
  44.              ||
  45.              opc2!=2 || opc2!=3 || opc2!=4){
  46.          
  47.          System.out.println("Uno de los números introducidor no es correcto");
  48.      }
  49.      
  50.      while (opc1==1 && opc2==2 || opc1==2 && opc2==2 || opc1==3 && opc2==3
  51.              || opc1==4 && opc2==4){
  52.          
  53.          System.out.println(" No se pueden pedir dos numeros iguales");
  54.          
  55.      }
  56.          
  57.          if (opc1==1 && opc2==2)  {
  58.              
  59.              W=num;
  60.              
  61.              MW=W*1000;
  62.              
  63.              System.out.println( MW +" MW ");
  64.              
  65.          }else if (opc1==2 && opc2==1){
  66.              
  67.              MW=num;
  68.              
  69.              W=MW/1000;
  70.              
  71.              System.out.println( W +" W ");
  72.              
  73.              
  74.          } else if (opc1==2 && opc2==4){
  75.              
  76.            MW=num;
  77.            
  78.            DBM=(float) (10*Math.log(MW));
  79.              
  80.            System.out.println( DBM +" DBM ");
  81.              
  82.            
  83.            
  84.          } else if (opc1==4 && opc2==2) {
  85.              
  86.              DBM=num;
  87.                              //BASE , EXPONENTE DBM /10
  88.              MW=(float) Math.pow(10, (DBM/10));
  89.              
  90.              
  91.              System.out.println( MW +" MW ");
  92.          
  93.          } else if (opc1==1 && opc2==3){
  94.              
  95.              W=num;
  96.              DBW=(float) (10*Math.log(W));
  97.              
  98.              System.out.println( DBW +" DBW ");
  99.              
  100.          } else if (opc1==3 && opc2==1){
  101.            
  102.              DBW=num;
  103.              W=(float) Math.pow(10, (DBW/10));
  104.              
  105.              System.out.println( W +" W ");
  106.              
  107.          } else if (opc1==3 && opc2==4){
  108.              
  109.              DBW=num;
  110.              
  111.              DBM=DBW+30;
  112.              
  113.              System.out.println( DBM +" DBM ");
  114.              
  115.          } else  if ( opc1==4 && opc2==3)  {
  116.              
  117.              
  118.              DBM=num;
  119.              
  120.              DBW=DBM-30;
  121.              
  122.              System.out.println( DBW +" DBW ");
  123.          }
  124.          
  125.        
  126.    
  127.          return num;
  128.          
  129.          
  130.      }
  131.    
  132.     /*  
  133.      *
  134.      *       if (opc1==4 && opc2==5){
  135.      *      
  136.      *       DBM=num;
  137.      *      
  138.      *       DBMV=DBM-90-10*Math.log(75);
  139.      *      
  140.      *       System.out.println( DBMV + " DBMV ");
  141.      *       }
  142.      *
  143.      *
  144.      *
  145.      *
  146.      *
  147.      *
  148.      */
  149.    
  150.    
  151.    
  152.     public static void main(String[] args) throws IOException {
  153.         // TODO Auto-generated method stub
  154.        
  155.     Decibelios d1=new Decibelios();
  156.    
  157.     d1.ConversorVatios(30);
  158.        
  159.        
  160.     System.out.println( "HOLAA ");
  161.     }
  162.  
  163. }
Advertisement
Add Comment
Please, Sign In to add comment