22
UNIVERSIDAD REGIONAL AUTÓNOMA DE LOS ANDES “UNIANDES” TEMA: PROGRAMACION EN JAVA ESTUDIANTE: Jonathan Israel DOCENTE: Luis Guallpa

Programas en netbeans

Embed Size (px)

DESCRIPTION

PROGRAMACION EN JAVA

Citation preview

Page 1: Programas en netbeans

UNIVERSIDAD REGIONAL AUTÓNOMA DE LOS

ANDES “UNIANDES”

TEMA:

PROGRAMACION EN JAVA

ESTUDIANTE:

Jonathan Israel

DOCENTE:

Luis Guallpa

SALUDO:::

Page 2: Programas en netbeans

package mensaje1;

/**

*

* @author Usuario

*/

public class Mensaje1 {

/**

* @param args the command line arguments

*/

public class Mensaje{

}

public static void main(String[] args) {

// TODO code application logic here

System.out.println("Hola compañeros les saluda su pana Jonathan");

}

}

DATOS PERSONALES

package misdatos;

Page 3: Programas en netbeans

/**

*

* @author Usuario

*/

public class MisDatos {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.append("Mis nombres: jonathan");

System.out.println("06/01/1992");

}

}

EXPRESIONES ARITMETICAS

package varexpresaritmeticas;

/**

*

* @author JONTAHANS

Page 4: Programas en netbeans

*/

public class VarExpresAritmeticas {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.println("El costo total de el Tv es:");

System.out.print(300*(1*0.15));

}

}

AREA DE UN TRINGULO EQUILATERO

package trianguloequilatero;

/**

*

* @author JONATHANS

*/

import java.util.*;

public class TrianguloEquilatero {

Page 5: Programas en netbeans

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

double lado;

double perimetro, area;

//se piede al usuario que introduzca por teclado el valor del lado

Scanner teclado = new Scanner(System.in);

System.out.println("Introduzca el valor del lado:>> ");

lado = teclado.nextInt();

perimetro = 3*lado;

double altura = Math.sqrt(lado*lado-(lado/2.0)*(lado/2.0));

area = lado*altura/2;

System.out.println("El area del triangulo de lado>> " + lado);

System.out.println("es: " + area);

System.out.println("El perimetro del triangulo de lado>> " + lado);

System.out.println("El perimetro:>> " + perimetro);

}

Page 6: Programas en netbeans

}

SOLICITUD DE DATOS

package solicituddatos;

/**

*

* @author JONATHANS

*/

import java.util.*;

public class SolicitudDatos {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

int SegunIniciales, Segundos, Minutos, Horas, Dias;

Scanner teclado = new Scanner(System.in);

System.out.println("Introduzca un número de segundos:>> ");

SegunIniciales = teclado.nextInt();

//se calculan los minutos y segundo se restan

Minutos = SegunIniciales /60;

Page 7: Programas en netbeans

Segundos = SegunIniciales %60;

//se calculan las horas y los minutos que restan

Horas = Minutos /60;

Minutos = Minutos %60;

//se calculan los dias y las horas que restan

Dias = Horas /24;

Horas = Horas %24;

System.out.println(SegunIniciales + "Segundos son>>>" + Dias + "Dias>>," + Horas + "Horas>>," + Minutos + "Minutos>> y" +Segundos+"Segundos>>.");

}

}

SENTENCIAS Y VARIABLES

package sentenciasvariables;

/**

*

* @author JONATHANS

*/

public class SentenciasVariables {

Page 8: Programas en netbeans

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

boolean exprecion;

int a=7;

exprecion = 2 * 5 < 5 * 2 || a + 1 < 10 && ++a % 2==0;

System.out.println("El valor de la exprecion es: " + exprecion);

exprecion = 3 < 2 || ++a > 6;

System.out.println("El valor de la exprecion es: " + exprecion);

exprecion = a++ < 10 && a % 2 == 0 && a <= 10;

System.out.println("El valor de la exprecion es: " + exprecion);

exprecion = a++ < 10 || a % 3 == 2;

System.out.println("El valor de la exprecion es: " + exprecion);

System.out.println("El valor de a es: " + a);

}

}

PEQUEÑO CALCULO DE NOTAS

package progrnotas;

Page 9: Programas en netbeans

/**

*

* @author Usuario

*/

public class ProgrNotas {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

System.out.println("Notas de Programación>>");

System.out.println("Primer parcial>>");

System.out.println(9);

System.out.println("Segundo parcial>>");

System.out.println(10);

System.out.print("Nota FINAL: ");

System.out.println(9.8);

}

}

Page 10: Programas en netbeans

PETICION DE VALORES

/

package peticionvalores;

/**

*

* @author Usuario

*/

import java.util.*;

public class PeticionValores {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

// El valor del nuemmro pi

final double PI = 3.1415926536;

double Radio;

double Altura;

Page 11: Programas en netbeans

Scanner teclado = new Scanner(System.in);

System.out.println("Introduzca los datos del cilindro: ");

Radio = teclado.nextDouble();

System.out .println("Altura:");

Altura = teclado.nextDouble();

System.out.print("El area del cilindro es:");

System.out.println(PI*Radio*Radio*Altura);

}

}

OPERADORES POST INCREMENTO

package operadoresprepostincremento;

/**

*

* @author Usuario

*/

public class OperadoresPrePostIncremento {

/**

* @param args the command line arguments

Page 12: Programas en netbeans

*/

public static void main(String[] args) {

// TODO code application logic here

int a=3,b=6,c;

c=a/b;

System.out.println("El valor de c es:>> "+c);

c=a%b;

System.out.println("Elvalor de c es:>> "+c);

a++;

System.out.println("El valoe de a es:" +a);

c=++a+b++;

System.out.println("El valor a es:"+a);

System.out.println("El valor b es:"+b);

System.out.println("El valor c es:"+c);

c=++a + b++;

System.out.println("El valor a es:"+a);

System.out.println("El valor b es:"+b);

System.out.println("El valor c es:"+c);

Page 13: Programas en netbeans

}

}

CLASE ATRIBUTOS

package humano;

/**

*

* @author Usuario

*/

public class Humano {

/**

* @param args the command line arguments

*/

String Nombre,Apellido;

int Edad;

public Humano(String nombre,String apellido, int edad)

{

this.Nombre=nombre;

this.Apellido=apellido;

this.Edad=edad;

}

Page 14: Programas en netbeans

public void MuestraNombre(){

System.out.println(Nombre);

System.out.println(Apellido);

System.out.println(Edad);

}

public static void main(String[] args) {

// TODO code application logic here

//Humano h1;

Humano h1=new Humano("Jonathan","Salguero",21);

h1.MuestraNombre();

}

}

DIAS DE LA SEMANA

package dias;

/**

*

* @author JONATHANS

*/

Page 15: Programas en netbeans

public class Dias {

public enum DiaSemana {LUNES,MARTES,MIERCOLES,JUEVES,VIERNES,SABADO,DOMINGO}

public static void main(String[] args) {

DiaSemana hoy = DiaSemana.VIERNES;

DiaSemana último = DiaSemana.DOMINGO;

System.out.println("Hoy es "+hoy);

System.out.println("El ultimo dia es"+último);

}

}

CLASE AUTO

package concsumoauto;

/**

*

* @author Usuario

*/

import java.util.*;

public class ConcsumoAuto {

Page 16: Programas en netbeans

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

double precioLitro, litros = 0;

double pagado, coste = 0;

int KmInicial, KmFinal, Kilometros;

Scanner teclado = new Scanner (System.in);

System.out.println("Introduzca el precio por litro: ");

precioLitro = teclado.nextInt();

System.out.println("Introduzca el costo total: ");

pagado = teclado.nextInt();

System.out.println("Introduzca el valor de cualquier Kilometro: ");

KmInicial = teclado.nextInt();

litros = pagado/precioLitro;

coste = pagado;

System.out.println();

Page 17: Programas en netbeans

System.out.println("Introduzca el precio por litro: ");

precioLitro = teclado.nextInt();

System.out.println("Introduzca el valor por segundo: ");

pagado = teclado.nextInt();

litros += pagado/precioLitro;

coste += pagado;

System.out.println();

System.out.println("Introduzca el valor de kilometros: ");

KmFinal = teclado.nextInt();

Kilometros = KmFinal - KmInicial;

System.out.println("El consumo del auto es de: " + (litros/Kilometros*100)+"litro por cada 100 km");

System.out.println("El gasto medio es: "+coste/Kilometros+"por kilometro");

}

}

AREA Y PERIMETRO DE UN RECTANGULO

*/

Page 18: Programas en netbeans

package areaperimetro;

/**

*

* @author Usuario

*/

public class AreaPerimetro {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

int alto = 15;

int ancho = 25;

int perimetro = 2 * alto + 2 * ancho;

int area = ancho * alto;

System.out.println("El Retangulo mide>>> " + alto + "de alto");

System.out.println("y" + ancho + "de ancho");

System.out.println("El Perimetro del retangulo es: " + perimetro);

System.out.println("El Área del retangulo es: " + area);

Page 19: Programas en netbeans

}

}