Programa para saber si un numero es positivo o negativo
package nombre;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class positivoonegativo {
public static void main(String[]args)throws IOException{
int a;
BufferedReader leer=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Introduce un numero para saber si es positivo o negativo");
String StrA;
StrA=leer.readLine();
System.out.println();
a=Integer.parseInt(StrA);
if (a>0)
System.out.println("Es positivo");
else
System.out.println("Es negativo");
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class positivoonegativo {
public static void main(String[]args)throws IOException{
int a;
BufferedReader leer=new BufferedReader(new InputStreamReader(System.in));
System.out.print("Introduce un numero para saber si es positivo o negativo");
String StrA;
StrA=leer.readLine();
System.out.println();
a=Integer.parseInt(StrA);
if (a>0)
System.out.println("Es positivo");
else
System.out.println("Es negativo");
}
}
Comentarios
Publicar un comentario