Java
El lenguaje JAVA define 8 tipos de datos primitivos
byte short int long
float double char Boolean
Números enteros: byte, short, int, long
Números en coma flotantefloat, doublé
Datos de tipo carácter char
Datos de tipo booleano boolean
Operadores aritméticos
JAVA incluye 5 operadores para realizar operaciones aritméticas
+
-
*
/
% Módulo (resto dela división)
class ejemplo2 {
public static void main( String args[] ) {
int a = 28;
int b = 4;
int c= 0;
// Programa en JAVA que suma 2 numeros
c=a+b;System.out.println( "El resultado es " +c );
}
}
class suma
{
public static void main(String args[])
{
int a=20;
int b=50;
int suma=0;
suma=a+b;System.out.println("La suma es" +suma);
}
}
class producto
{
public static void main(String args[])
{
int a=10;
int b=20;
int c=5;
int multip1=0;
intmultip2=0;
multip1=a*b;
multip2=a*c;
System.out.println("a * b = " + multip1);
System.out.println("a * c = " + multip2);
}
}
// Ejemplo 1.2
import java.io.*;
publicclass leer
{
public static void main(String[] args) throws IOException
{
InputStreamReader lector = new
InputStreamReader(System.in);
BufferedReader input = newBufferedReader(lector);
System.out.print("Escribe tu nombre: ");
String nombre = input.readLine();
System.out.println("Hola, " + nombre + "!");
}
}
// Ejemplo 1.2
import java.io.*;
public classleer2
{
public static void main(String[] args) throws IOException
{
InputStreamReader lector = new
InputStreamReader(System.in);
BufferedReader input = newBufferedReader(lector);
System.out.print("Escribe tu nombre: ");
String nombre = input.readLine();
System.out.print("Escribe pasatiempo: ");
String pasatiempo = input.readLine();
System.out.println("Hola, "...
Regístrate para leer el documento completo.