import java.util.Scanner;
/**
*
* @author jnieto
*/
public class Ejercicio380MeCaso {
public static void main(String[] args) {
Scanner leer= new Scanner(System.in);
int num,suma;
do {
num=leer.nextInt();
suma=0;
for (int i = 0; i < num; i++) {
suma+=leer.nextInt();
}
if(num!=0) System.out.println(suma);
} while (num!=0);
}
}
Este blog está dedicado a la recolección de información relacionada con las nuevas tecnologías ( tecnoloxía xa), especialmente, con las vinculadas a la informática. La idea es centralizar y compartir la información y cada manual o tutorial que voy recolectando para las clases tanto de administración de sistemas como de explotación de sistemas informáticos de modo que estén disponibles para alumnos y resto de interesados. (IES A Carballeira, Ourense)
Mostrando entradas con la etiqueta DAM. Mostrar todas las entradas
Mostrando entradas con la etiqueta DAM. Mostrar todas las entradas
viernes, 3 de noviembre de 2017
Me Caso (Acepta el reto 380)
Etiquetas:
acepta el reto,
DAM,
daw,
programación
Hola Mundo (Acepta el reto 116)
import java.util.Scanner;
public class Ejercicio116 {
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
int casos;
casos = leer.nextInt();
for (int i = 0; i < casos; i++) {
System.out.println("Hola mundo.");
}
}
public class Ejercicio116 {
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
int casos;
casos = leer.nextInt();
for (int i = 0; i < casos; i++) {
System.out.println("Hola mundo.");
}
}
Etiquetas:
acepta el reto,
DAM,
daw,
programación
Rellenando El Agua De La Fuente (Acepta el reto 360)
import java.util.Scanner;
public class Ejercicio360RellenandoElAguaDeLaFuente {
public static void main(String[] args) {
Scanner leer =new Scanner(System.in);
int max,min,actual,casos,perdida,dias;
public class Ejercicio360RellenandoElAguaDeLaFuente {
public static void main(String[] args) {
Scanner leer =new Scanner(System.in);
int max,min,actual,casos,perdida,dias;
Etiquetas:
acepta el reto,
DAM,
daw,
programación
¿Qué lado de la calle? (Acepta el reto 217)
import java.util.Scanner;
public class Ejercicio217 {
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
int num;
do {
num = leer.nextInt();
if (num != 0) {
if (num % 2 != 0) {
Etiquetas:
acepta el reto,
DAM,
daw,
programación,
programame
jueves, 30 de abril de 2015
package corredoresporpaises;
import java.util.ArrayList;
/**
*
* @author juan
*/
public class Pais {
private String nombre;
private ArrayList corredores;
public ArrayList getCorredores() {
return corredores;
}
public void setCorredores(ArrayList corredores) {
this.corredores = corredores;
}
public Pais(String nombre) {
this.nombre = nombre;
corredores = new ArrayList<>();
}
public String getNombre() {
return nombre;
}
public boolean anhade(Corredor nuevo) {
boolean retorno = true;
try {
if (corredores.contains(nuevo)){
System.out.println("El corredor ya estaba incluido");
}
else
{
nuevo.setPais(this);
corredores.add(nuevo);
}
} catch (Exception e) {
retorno=false;
}
return retorno;
}
public void listarCorredores(){
System.out.println(nombre);
System.out.println("==============");
for (Corredor corredor : corredores) {
System.out.println(corredor);
}
}
import java.util.ArrayList;
/**
*
* @author juan
*/
public class Pais {
private String nombre;
private ArrayList
public ArrayList
return corredores;
}
public void setCorredores(ArrayList
this.corredores = corredores;
}
public Pais(String nombre) {
this.nombre = nombre;
corredores = new ArrayList<>();
}
public String getNombre() {
return nombre;
}
public boolean anhade(Corredor nuevo) {
boolean retorno = true;
try {
if (corredores.contains(nuevo)){
System.out.println("El corredor ya estaba incluido");
}
else
{
nuevo.setPais(this);
corredores.add(nuevo);
}
} catch (Exception e) {
retorno=false;
}
return retorno;
}
public void listarCorredores(){
System.out.println(nombre);
System.out.println("==============");
for (Corredor corredor : corredores) {
System.out.println(corredor);
}
}
Etiquetas:
DAM,
java,
programación,
tema3
jueves, 12 de febrero de 2015
ejercicio 11 tema3, números aleatorios
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio11;
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio11 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int [] lista = new int [25];
float [] auxi = new float[4];
Random al = new Random();
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio11;
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio11 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int [] lista = new int [25];
float [] auxi = new float[4];
Random al = new Random();
Etiquetas:
DAM,
ejercicios,
tema3
lunes, 9 de febrero de 2015
Clase monitor con uso en un array para buscar repeticiones
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package preparacion4;
/**
*
* @author juan
*/
public class Monitor {
String Fabricante;
int Pulgadas;
int ResolucionH;
int ResolucionV;
String Modelo;
public Monitor() {
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package preparacion4;
/**
*
* @author juan
*/
public class Monitor {
String Fabricante;
int Pulgadas;
int ResolucionH;
int ResolucionV;
String Modelo;
public Monitor() {
}
Etiquetas:
DAM,
ejercicios,
tema3
jueves, 5 de febrero de 2015
Tema 3 ejercicio 8: Creando vector de ecuaciones de segundo grado
package ejercicio8;
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio8 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Random al = new Random();
EcuacionSegundoGrado [] vector = new EcuacionSegundoGrado [5];
int contIncorrectas;
for (int i = 0; i < 5; i++) {
Etiquetas:
DAM,
ejercicios,
programación
miércoles, 4 de febrero de 2015
Ejercicio 6 Tema 3: Comprobar nif usando arrays
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio5;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Ejercicio5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
char [] letras ={'T','R','W','A','G','M','Y','F', 'P', 'D','X','B', 'N', 'J', 'Z', 'S', 'Q','V', 'H', 'L', 'C', 'K','E', };
String cadena;
int numDni;
int resto;
char letra;
String numeros;
int cont =0;
boolean esNumero;
Scanner leer = new Scanner(System.in);
Etiquetas:
DAM,
programación,
tema3
Ejercicio 5 Tema 3: Calcular el NIF usando arrays
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio5;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Ejercicio5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
char [] letras ={'T','R','W','A','G','M','Y','F', 'P', 'D','X','B', 'N', 'J', 'Z', 'S', 'Q','V', 'H', 'L', 'C', 'K','E', };
int numDni;
int resto;
Scanner leer = new Scanner(System.in);
System.out.println("Introduzca su dni: ");
numDni= leer.nextInt();
resto = numDni%23;
System.out.println(letras[resto]);
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio5;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Ejercicio5 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
char [] letras ={'T','R','W','A','G','M','Y','F', 'P', 'D','X','B', 'N', 'J', 'Z', 'S', 'Q','V', 'H', 'L', 'C', 'K','E', };
int numDni;
int resto;
Scanner leer = new Scanner(System.in);
System.out.println("Introduzca su dni: ");
numDni= leer.nextInt();
resto = numDni%23;
System.out.println(letras[resto]);
}
}
Etiquetas:
DAM,
programación,
tema3
lunes, 2 de febrero de 2015
ejercicio 4 tema3
package ejercicio4;
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int [] numeros = new int[100];
int [] ocurren = new int[10];
Random r = new Random();
int cont;
for (int i = 0; i < numeros.length; i++) {
numeros[i]= r.nextInt(31)+20;
}
cont=0;
for (int i = 0; i < numeros.length; i++) {
System.out.print(numeros[i]+",");
++cont;
if (cont==20) {
System.out.println("");
cont=0;
}
}
for (int num : numeros) {
if (num>20 && num <31 p=""> ocurren[(num-21)]++;
}
for (int i = 0; i < ocurren.length; i++) {
System.out.println("El número: "+ (21+i)+ " aparece "+ ocurren[i]+ " veces");
}
/*
switch (num) {
case 21: ocurren[0]++;break;
case 22: ocurren[1]++;
break;
break;
default:
throw new AssertionError();
}
*/
}
}
31>
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int [] numeros = new int[100];
int [] ocurren = new int[10];
Random r = new Random();
int cont;
for (int i = 0; i < numeros.length; i++) {
numeros[i]= r.nextInt(31)+20;
}
cont=0;
for (int i = 0; i < numeros.length; i++) {
System.out.print(numeros[i]+",");
++cont;
if (cont==20) {
System.out.println("");
cont=0;
}
}
for (int num : numeros) {
if (num>20 && num <31 p=""> ocurren[(num-21)]++;
}
for (int i = 0; i < ocurren.length; i++) {
System.out.println("El número: "+ (21+i)+ " aparece "+ ocurren[i]+ " veces");
}
/*
switch (num) {
case 21: ocurren[0]++;break;
case 22: ocurren[1]++;
break;
break;
default:
throw new AssertionError();
}
*/
}
}
Ejercicio 3 tema 3
package ejercicio3;
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
long t0;
int [] resultado = new int [6];
Random tirada = new Random();
t0 = System.currentTimeMillis();
for (int i = 0; i < 100000000; i++) {
resultado[tirada.nextInt(6)]++;
}
for (int i = 0; i < resultado.length; i++) {
System.out.println((i+1 )+":"+resultado[i]);
}
System.out.println("Tiempo (milisegundos): "+(System.currentTimeMillis()-t0));
}
}
import java.util.Random;
/**
*
* @author juan
*/
public class Ejercicio3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
long t0;
int [] resultado = new int [6];
Random tirada = new Random();
t0 = System.currentTimeMillis();
for (int i = 0; i < 100000000; i++) {
resultado[tirada.nextInt(6)]++;
}
for (int i = 0; i < resultado.length; i++) {
System.out.println((i+1 )+":"+resultado[i]);
}
System.out.println("Tiempo (milisegundos): "+(System.currentTimeMillis()-t0));
}
}
Etiquetas:
DAM,
ejercicio3,
tema3
jueves, 22 de enero de 2015
Clase fecha (80) v2.0
package ejercicio80;
/**
*
* @author juan
*/
public class Fecha {
private int dia;
private int mes;
private int anyo;
/**
* Constructor por defecto genera fechas al 1 del 1 del 2013
*/
public Fecha() {
this.dia = 1;
this.mes = 1;
this.anyo = 2013;
}
/**
* Constructor al que les pasamos tres parámetros si la fecha es posible se
* le asigna en caso de fecha incorrecta inicializa el objeto al 1-1-2013
*
* @param dia representa el día de la fecha completa
* @param mes mes de la fecha
* @param anyo año de la fecha
*/
public Fecha(int dia, int mes, int anyo) {
if (comprobarFecha(dia, mes, anyo)) {
this.dia = dia;
this.mes = mes;
this.anyo = anyo;
} else {
this.dia = 1;
this.mes = 1;
this.anyo = 2013;
}
}
/**
* Permite asignar día, mes y anyo al objeto fecha. Si la asignación es
* correcta devuelve true, en caso contrario false.
*
* @param dia día del año que se quiere asignar
* @param mes mes del año en formato numérico
* @param anyo año en formato numérico
* @return true si la fecha asignada es posible, false en caso contrario
*/
public boolean asignate(int dia, int mes, int anyo) {
boolean retorno = false;
if (comprobarFecha(dia, mes, anyo)) {
this.dia = dia;
this.mes = mes;
this.anyo = anyo;
/**
*
* @author juan
*/
public class Fecha {
private int dia;
private int mes;
private int anyo;
/**
* Constructor por defecto genera fechas al 1 del 1 del 2013
*/
public Fecha() {
this.dia = 1;
this.mes = 1;
this.anyo = 2013;
}
/**
* Constructor al que les pasamos tres parámetros si la fecha es posible se
* le asigna en caso de fecha incorrecta inicializa el objeto al 1-1-2013
*
* @param dia representa el día de la fecha completa
* @param mes mes de la fecha
* @param anyo año de la fecha
*/
public Fecha(int dia, int mes, int anyo) {
if (comprobarFecha(dia, mes, anyo)) {
this.dia = dia;
this.mes = mes;
this.anyo = anyo;
} else {
this.dia = 1;
this.mes = 1;
this.anyo = 2013;
}
}
/**
* Permite asignar día, mes y anyo al objeto fecha. Si la asignación es
* correcta devuelve true, en caso contrario false.
*
* @param dia día del año que se quiere asignar
* @param mes mes del año en formato numérico
* @param anyo año en formato numérico
* @return true si la fecha asignada es posible, false en caso contrario
*/
public boolean asignate(int dia, int mes, int anyo) {
boolean retorno = false;
if (comprobarFecha(dia, mes, anyo)) {
this.dia = dia;
this.mes = mes;
this.anyo = anyo;
Etiquetas:
DAM,
ejercicios,
explicación
viernes, 16 de enero de 2015
Ecuaciones de segundo grado. Ejercicio 79
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio79;
/**
*
* @author juan
*/
public class EcuacionSegundoGrado {
private int a;
private int b;
private int c;
public EcuacionSegundoGrado(int a, int b, int c) {
this.a = a;
this.b = b;
this.c = c;
}
Etiquetas:
DAM,
ejercicios,
programación
jueves, 11 de diciembre de 2014
Buscar un número en un array
package busquedaenarray;
import java.util.Scanner;
import java.util.Arrays;
import java.util.Random;
/**
*
* @author juan
*/
public class BusquedaEnArray {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Random al = new Random();
Etiquetas:
DAM,
ejercicios,
programación
Ejercicio 69: Calcular el máximo común divisor de dos números mediante el método de Euclídes
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio69;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Ejercicio69 {
Etiquetas:
DAM,
ejercicios,
programación
miércoles, 10 de diciembre de 2014
Leer 10 notas usando arrays y calcular la media y la nota mayor
package notasymayorconarrays;
import java.util.Scanner;
/**
*
* @author juan
*/
public class NotasYMayorConArrays {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
int [] notas= new int[10];
int total, media, mayor;
Etiquetas:
DAM,
ejercicios,
programación
Empezando con arrays
package explicacionarray;
import java.util.Scanner;
/**
*
* @author juan
*/
public class ExplicacionArray {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int [] unArray;
int [] otroArray = new int[20];
int lon=10;
Scanner leer = new Scanner(System.in);
Etiquetas:
DAM,
explicación,
programación
jueves, 4 de diciembre de 2014
Explicación cadenas
package buscarunapalabra;
import java.util.Scanner;
/**
*
* @author juan
*/
public class BuscarunaPalabra {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
boolean encontrada=false;
int pos=0,cont,coinciden=0;
String cadena, buscada;
System.out.println("Introduzca la cadena a buscar");
cadena= leer.nextLine();
System.out.println("Introduzca palabra: ");
buscada= leer.nextLine();
cont=0;
while (!encontrada && cont <= (cadena.length()-buscada.length()))
{
if (cadena.charAt(cont)==buscada.charAt(0))
{
Etiquetas:
DAM,
ejercicios,
programación
lunes, 1 de diciembre de 2014
Ejercicio 46
Autor: Miguel Ángel Romero
package ejer46;
import java.util.Scanner;
/**
*
* @author juan
*/
public class Ejer46 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner leer = new Scanner(System.in);
int num;
do {
System.out.println("Introduzca un número por teclado entre 3 y 10:");
num = leer.nextInt();
} while (num < 3 || num > 15 || num % 2 == 0);
for (int i = 1; i < num; i = i + 2) {
for (int k = i; k < num; k = k + 2) {
System.out.print(" ");
}
for (int j = 0; j < i; j++) {
if (j == 0 || j == i - 1) {
System.out.print("*");
} else {
System.out.print(" ");
}
Etiquetas:
DAM,
programacion
Suscribirse a:
Entradas (Atom)