UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Resuelto 23



23.- RESOLVER LA ECUACIÓN DE PRIMER GRADO:

ax+b=0        x=-b
                          a

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package problema023;
import java.io.*;
/**
 *
 * @author abel montalvan
 */
public class PROBLEMA023 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException{
      float a,b,x;
 BufferedReader in=new BufferedReader(new  InputStreamReader(System.in));
 System.out.println("a: ");
 a=Float.parseFloat(in.readLine());
 System.out.println("b: ");
 b=Float.parseFloat(in.readLine());
 if(a!=0)
 {
   x=-b/a;
 }
 else
 {
   x=0;
 }
 System.out.println("");
 System.out.println("x: " + x);
 System.out.println();
    }
}

No hay comentarios:

Publicar un comentario