Today I upgraded PHPMyAdmin from version 5.1.1 to version 5.1.2 and got a warning with the following message: [Undefined array key "hide_connection_errors"].
If anyone knows how to fix it, please share the solution, thank you very much.
I come across an error that I am not able to solve, the fact is that after making some example codes and testing them with the Tomcat 10 server that I have installed, they work fine but in the dynamic web project, specifically the web.xml file gives me error, I attach a photo and code in case someone knows how to solve it, although I have tried to change j2ee for javaee and the label continues to give me an error.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>otro</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
I have tried to put 2.4 and the error disappears on line 2 version="2.5" but the file continues with the error and also the error continues, thank you very much in advance.
All the best
I have created a program that asks the user for an amount in euros and calculates the number of bills needed to cover that amount and the rest in coins of 1, 2, 0.5, 0.20, 0.10, 0.05, 0.02, 0.01. The types of bills are: 500, 200, 100, 50, 20, 10 and 5.
The fact is that it works but not quite right because if I put for example 257.27 it returns me: There are 1.0 bills of: 200.0 Euros There are 1.0 bills of: 50.0 Euros There are 1.0 bills of: 5.0 Euros There are 1.0 coins of: 2.0 Euros There are 1.0 coins of: 0.2 Euros There are 1.0 coins of: 0.05 Euros There are 1.0 coins of: 0.01 Euros
Where we see that 1 cent of a euro is missing or what is the same, there should have been 2 coins of 2 cents (0.02)
I attach my code to see if anyone sees what I'm doing wrong.
Thank you very much in advance and I hope it will be of some use to you and you like it, greetings.
import java.util.*;
public class Euroscompleto {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Declaro variable que contendra el valor a devolver
double importe = 0;
do {
try {
System.out.print("Ingresa el cambio a devolver:");
importe = sc.nextDouble();
} catch (Exception e) {
System.out.println("Introduciste un dato erroneo.");
System.out.println("");
sc.nextLine();
}
}
while (importe <= 0);
calcular(importe);
sc.close();
}
// Método para calcular
public static void calcular(double importe) {
// Indicamos todas las monedas posibles
double[] monedas = { 500, 200, 100, 50, 20, 10, 5, 2, 1, 0.5, 0.20, 0.10, 0.05, 0.02, 0.01 };
// Creamos un array con 0 de longitud igual a la cantidad de monedas
// Este array contendra las monedas a devolver
double[] devolver = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
// Recorremos todas las monedas
for (int i = 0; i < monedas.length; i++) {
// Si el importe actual, es superior a la moneda
if (importe >= monedas[i]) {
// obtenemos cantidad de monedas
devolver[i] = Math.floor(importe / monedas[i]);
// actualizamos el valor del importe que nos queda por didivir
importe = importe - (devolver[i] * monedas[i]);
}
}
// Bucle para mostrar el resultado
for (int i = 0; i < monedas.length; i++) {
if (devolver[i] > 0) {
if (monedas[i] > 2) {
// Indicamos que es un billete
System.out.println("Hay " + devolver[i] + " billetes de: " + monedas[i] + " Euros");
} else {
// Indicamos que es una moneda
System.out.println("Hay " + devolver[i] + " monedas de: " + monedas[i] + " Euros");
}
}
}
}
}
I have been offered a mobile application where you ask for the position of a prime number and it returns the prime number in that position. Specifically, I start by storing only the prime numbers in an ArrayList and then I have optimized everything that has occurred to me so as not to block the mobile but in the end it explodes, I don't know what further optimizations to make, can someone help me please? Thank you very much and greetings to all.
Here I show the code:
All of the following is inside a package and I import the corresponding libraries, which I do not put here because it gives me an error and does not let me publish.
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
static ArrayList<Integer> nprimos = new ArrayList<Integer>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setLogo(R.mipmap.ic_launcher);
getSupportActionBar().setDisplayUseLogoEnabled(true);
Button btnCalcular=findViewById(R.id.btnCalcular);
btnCalcular.setOnClickListener(this);
int numero=2;
boolean primo=false;
nprimos.add(1);//Hago un add inicial en el ArrayList
for(int j=0;j<100000;j++){//Hago el bucle for hasta 100000 posiciones
primo=true;
for(int i=2; i<nprimos.size(); i++)//Hago el bucle for mientras sea menor del tamaño
//del ArrayList
{
if(numero%nprimos.get(i)==0) {//divide solo entre los números primos
primo = false;//Si no es primo
break;//termina el for y salta a numero++
}
}
if(primo)
{//Si el número es primo le añado al ArrayList
nprimos.add(numero);
}//incremento la variable número y sube arriba para hacer la division en el if
//mientras j siga siendo menor de 100000
numero++;
}
}
public void onClick(View v){
EditText ed1=findViewById(R.id.ed1);
int num = Integer.parseInt(ed1.getText().toString());
TextView t=findViewById(R.id.txtResultado);
//Al pinchar ya empezamos con un ArrayList lleno de números primos
if(num<nprimos.size()){
t.setText("El número primo es: "+nprimos.get(num));
}
else{
int contador=0;
int limite=num-nprimos.size();
int numero=nprimos.get(nprimos.size()-1);
boolean primo=false;
while(contador!=limite) {
primo=true;
for(int i=2; i<nprimos.size(); i++)
{
if(numero%nprimos.get(i)==0) {
primo=false;
break;
}
}
if(primo)
{
contador++;
nprimos.add(numero);
}
numero++;
}
t.setText("El número primo es: "+nprimos.get(num-1));
}
}
}