Eclipse
import java.util.Scanner;
public class triangulo
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
int base, altura, area;
System.out.println("digite altura: ");
altura = Leer.nextInt();
System.out.println("digite la base: ");
base = Leer.nextInt();
area = base * altura / 2;System.out.println("el area es " + area);
}
}
EJERICIO 2: NOTAS
import java.util.Scanner;
public class notas
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
String nombre;
double nota1, nota2, nota3, nota4, prome;
System.out.println("NOMBRE: ");
nombre = Leer.next();
System.out.println("nota1: ");
nota1 =Leer.nextDouble();
System.out.println("nota2: ");
nota2 = Leer.nextDouble();
System.out.println("nota3: ");
nota3 = Leer.nextDouble();
System.out.println("nota4: ");
nota4 = Leer.nextDouble();
prome = (nota1 + nota2 + nota3 + nota4)/4;
System.out.println("EL PROMEDIO DE " + nombre + " ES DE " + prome);
}
}
EJERICIO3:PRECIO DE VENTA
import java.util.Scanner;
public class EJERICIO3
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
String nombre;
double ctoprod, precventa, utilidad, impuesto;
System.out.println("nombre: ");
nombre = Leer.next();
System.out.println("ctoprod: ");
ctoprod = Leer.nextDouble();precventa = (ctoprod*2.2)*1.15;
System.out.println("EL PRECIO DEL PRODUCTO ES DE: " + precventa);
}
}
EJERCICIOS TALLER 2:
EJERCICIO SI CONDICIONAL
import java.util.Scanner;
public class ejerciciosi
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
int edadI, edadD;
System.out.println("EDAD DE INGRID: ");
edadI= Leer.nextInt();
System.out.println("EDAD DE DIANA: ");
edadD = Leer.nextInt();
if (edadI > edadD)
{
System.out.println("INGRID ES LA MAYOR");
}
else
{
System.out.println("DIANA ES LA MAYOR");
}
}
}
EJERICICIO SI ANIDADO
import java.util.Scanner;
public class sianidado
{
public static void main(String[] args)
{
ScannerLeer = new Scanner(System.in);
int edadI, edadD;
System.out.println("EDAD DE INGRID: ");
edadI = Leer.nextInt();
System.out.println("EDAD DE DIANA: ");
edadD = Leer.nextInt();
if (edadI == edadD)
System.out.println("EDADES IGUALES");
else
{
if(edadI > edadD )
System.out.println("INGRID ES MAYOR");
else
System.out.println("DIANA ESMAYOR");
}
}
}
import java.util.Scanner;
public class punto5
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
int edadI, edadD;
System.out.println("EDAD DE INGRID: ");
edadI = Leer.nextInt();
System.out.println("EDAD DE DIANA: ");
edadD = Leer.nextInt();
if (edadI > edadD)
{System.out.println("INGRID ES MAYOR");
}
else
{
if (edadD > edadI)
{
System.out.println("DIANA ES MAYOR");
}
else
{
System.out.println("EDADES IGUALES");
}
}
}
}
import java.util.Scanner;
public class punto6
{
public static void main(String[] args)
{
Scanner Leer = new Scanner(System.in);
int nhoras, vlrhora, ne1, ne2, vlre1, vlre2,total1 = 0, total2 = 0, total3 = 0, grantotal, vlrhn;
System.out.println("NUMERO DE HORAS: ");
nhoras = Leer.nextInt();
System.out.println("VALOR HORA");
vlrhora = Leer.nextInt();
if (nhoras num2)
{
System.out.println("PRIMER NUMERO ES MAYOR");
}
else
{
if (num2 > num1)
{
System.out.println("SEGUNDO NUMERO ES MAYOR");
}
else
{...
Regístrate para leer el documento completo.