Jump to content

Renan Alves

Membros
  • Contagem de Conteúdo

    62
  • Ingressou

  • Última visita

  • Dias Ganhos

    1

Renan Alves ganhou o dia em Fevereiro 22

Renan Alves teve o conteúdo mais curtido!

Informações Pessoais

  • Cidade
    Gama
  • Estado
    Distrito Federal (DF)

Clientes & Parceiros

  • Você é um cliente TecnoSpeed?
    Não

Visitantes Recentes do Perfil

O bloco de visitantes recentes está desativado e não está sendo mostrado a outros usuários.

Conquistas de Renan Alves

  1. beecrowd | 1067 Odd Numbers Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read an integer value X (1 <= X <= 1000). Then print the odd numbers from 1 to X, each one in a line, including X if is the case. Input The input will be an integer value. Output Print all odd values between 1 and X, including X if is the case. import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int n, i; n = sc.nextInt(); for(i = 1; i <= n; i++) { if(i % 2 != 0) { System.out.println(i); } } sc.close(); } }
  2. beecrowd | 1066 Even, Odd, Positive and Negative Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Make a program that reads five integer values. Count how many of these values are even, odd, positive and negative. Print these information like following example. Input The input will be 5 integer values. Output Print a message like the following example with all letters in lowercase, indicating how many of these values are even, odd, positive and negative. import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int n, i, impa = 0, par = 0, negativo = 0, positivo = 0; for(i = 1; i <= 5; i++) { n = sc.nextInt(); if(n < 0 || n > 0) { if(n > 0) { positivo++; } else { negativo++; } } if(n % 2 != 0 || n % 2 == 0) { if(n % 2 != 0) { impa++; } else { par++; } } } System.out.println(par + " valor(es) par(es)"); System.out.println(impa + " valor(es) impar(es)"); System.out.println(positivo + " valor(es) positivo(s)"); System.out.println(negativo + " valor(es) negativo(s)"); sc.close(); } }
  3. beecrowd | 1065 Even Between five Numbers Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Make a program that reads five integer values. Count how many of these values are even and print this information like the following example. Input The input will be 5 integer values. Output Print a message like the following example with all letters in lowercase, indicating how many even numbers were typed. Resolução: import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int n, i, p = 0; for(i = 1; i <= 5; i++) { n = sc.nextInt(); if(n % 2 == 0) { p++; } } System.out.println(p + " valores pares"); sc.close(); } }
  4. beecrowd | 1064 Positives and Average Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read 6 values that can be floating point numbers. After, print how many of them were positive. In the next line, print the average of all positive values typed, with one digit after the decimal point. Input The input consist in 6 numbers that can be integer or floating point values. At least one number will be positive. Output The first output value is the amount of positive numbers. The next line should show the average of the positive values typed. Resolução: import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); double n, positivo = 0, media = 0; for(int i = 1; i <= 6; i++) { n = sc.nextDouble(); if(n >= 0) { media += n; positivo++; } } media /= positivo; System.out.printf("%.0f valores positivos\n", positivo); System.out.printf("%.1f\n", media); } }
  5. beecrowd | 1061 Event Time Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Peter is organizing an event in his University. The event will be in April month, beginning and finishing within April month. The problem is: Peter wants to calculate the event duration in seconds, knowing obviously the begin and the end time of the event. You know that the event can take from few seconds to some days, so, you must help Peter to compute the total time corresponding to duration of the event. Input The first line of the input contains information about the beginning day of the event in the format: “Dia xx”. The next line contains the start time of the event in the format presented in the sample input. Follow 2 input lines with same format, corresponding to the end of the event. Output Your program must print the following output, one information by line, considering that if any information is null for example, the number 0 must be printed in place of W, X, Y or Z: W dia(s) X hora(s) Y minuto(s) Z segundo(s) Obs: Consider that the event of the test case have the minimum duration of one minute. “dia” means day, “hora” means hour, “minuto” means minute and “Segundo” means second in Portuguese. Resolução: import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); String d, p; int dia1, hora1, minuto1, segundo1; int dia2, hora2, minuto2, segundo2; //hora inicial; d = sc.next(); dia1 = sc.nextInt(); hora1 = sc.nextInt(); p = sc.next(); minuto1 = sc.nextInt(); p = sc.next(); segundo1 = sc.nextInt(); //fim do evento; d = sc.next(); dia2 = sc.nextInt(); hora2 = sc.nextInt(); p = sc.next(); minuto2 = sc.nextInt(); p = sc.next(); segundo2 = sc.nextInt(); int inicio = 24 * 60 * 60 * dia1 + hora1 * 60 * 60 + minuto1 * 60 + segundo1; int fim = 24 * 60 * 60 * dia2 + hora2 * 60 * 60 + minuto2 * 60 + segundo2; int fim_Do_Evento = (fim - inicio) / (24 * 60 * 60); int dia = (fim - inicio) % (24 * 60 * 60); int hora = dia / (60 * 60); int resto = dia % (60 * 60); int minuto = resto / 60; int segundo = resto % 60; System.out.println(fim_Do_Evento + " dia(s)"); System.out.println(hora + " hora(s)"); System.out.println(minuto + " minuto(s)"); System.out.println(segundo + " segundo(s)"); sc.close(); } }
  6. beecrowd | 1060 Positive Numbers Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Write a program that reads 6 numbers. These numbers will only be positive or negative (disregard null values). Print the total number of positive numbers. Input Six numbers, positive and/or negative. Output Print a message with the total number of positive numbers. Resolução: import java.util.Locale; import java.util.Scanner; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); double n; int positivo = 0; for (int i = 1; i <= 6; i++) { n = sc.nextDouble(); if (n >= 0) { positivo++; } } System.out.println(positivo + " valores positivos"); sc.close(); } }
  7. beecrowd | 1059 Even Numbers Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Write a program that prints all even numbers between 1 and 100, including them if it is the case. Input In this extremely simple problem there is no input. Output Print all even numbers between 1 and 100, including them, one by row. Resolução: public class Main { public static void main(String[] args) { for(int i = 1; i <= 100; i++) { if(i % 2 == 0) { System.out.println(i); } } } }
  8. beecrowd | 1052 Month Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read an integer number between 1 and 12, including. Corresponding to this number, you must print the month of the year, in english, with the first letter in uppercase. Input The input contains only an integer number. Output Print the name of the month according to the input number, with the first letter in uppercase. Sintaxe opcional - Switch case: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int mounth; String mes; switch(mounth = sc.nextInt()) { case 1: mes = "January"; break; case 2: mes = "February"; break; case 3: mes = "March"; break; case 4: mes = "April"; break; case 5: mes = "May"; break; case 6: mes = "June"; break; case 7: mes = "July"; break; case 8: mes = "August"; break; case 9: mes = "September"; break; case 10: mes = "October"; break; case 11: mes = "November"; break; default: mes = "December"; } System.out.println(mes); sc.close(); } }
  9. Parece que há um erro na chamada do método consultar() na classe ProcessoDAO. Na classe Botão, você está tentando chamar o método consultar(parte1) da classe ProcessoDAO, mas na classe ProcessoDAO, o método correspondente é chamado getProcesso(parte1). Para corrigir isso, você pode alterar a chamada do método na classe Botão para getProcesso(parte1): javaCopy code Processo processo = dao.getProcesso(parte1); Além disso, é importante verificar se a conexão com o banco de dados está sendo estabelecida corretamente na classe ProcessoDAO antes de executar a consulta. Certifique-se de que pst está sendo inicializado com uma conexão preparada contendo o SQL correto. Outro ponto a ser observado é que parece haver um erro na definição do tipo de dados para os atributos distribuicao, num_proc e vara na classe Processo. Na classe Processo, esses atributos são definidos como int, mas na classe ProcessoDAO, ao recuperar os valores do banco de dados, eles são tratados como String. Certifique-se de que o tipo de dados na classe Processo corresponda ao tipo de dados no banco de dados. Além disso, certifique-se de que os índices de parâmetros no método setString() correspondam aos parâmetros corretos no seu SQL. No seu caso, você está passando 6 como o índice de parâmetro, mas você só tem um parâmetro no seu SQL (?), então o índice deve ser 1. Assumindo que pst é uma instância de PreparedStatement, você deve configurar o parâmetro da seguinte forma: javaCopy code pst.setString(1, parte1); Essas correções devem ajudar a resolver o problema que você está enfrentando. Certifique-se também de verificar se não há outros erros no código que possam estar afetando o funcionamento correto.
  10. beecrowd | 1051 Taxes By Neilor Tonin, URI Brasil Timelimit: 1 In an imaginary country called Lisarb, all the people are very happy to pay their taxes because they know that doesn’t exist corrupt politicians and the taxes are used to benefit the population, without any misappropriation. The currency of this country is Rombus, whose symbol is R$. Read a value with 2 digits after the decimal point, equivalent to the salary of a Lisarb inhabitant. Then print the due value that this person must pay of taxes, according to the table below. Remember, if the salary is R$ 3,002.00 for example, the rate of 8% is only over R$ 1,000.00, because the salary from R$ 0.00 to R$ 2,000.00 is tax free. In the follow example, the total rate is 8% over R$ 1000.00 + 18% over R$ 2.00, resulting in R$ 80.36 at all. The answer must be printed with 2 digits after the decimal point. Input The input contains only a float-point number, with 2 digits after the decimal point. Output Print the message "R$" followed by a blank space and the total tax to be payed, with two digits after the decimal point. If the value is up to 2000, print the message "Isento". Resolução: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); double valor, taxas = 0; valor = sc.nextDouble(); if(valor >= 0 && valor <= 2000.0) { System.out.println("Isento"); } else if(valor > 2000.0 && valor <= 3000.0) { taxas = (valor - 2000) / 100.0 * 8.0; } else if(valor > 3000.0 && valor <= 4500.0) { taxas = (valor - 3000.0) / 100.0 * 18.0 + 1000.0 / 100.0 * 8.0; } else { taxas = (valor - 4500.0) / 100.0 * 28.0 + 1500.0 / 100 * 18.0 + 1000.0 / 100.0 * 8.0; } if(taxas > 0.0) { System.out.printf("R$ %.2f\n" , taxas); } sc.close(); } }
  11. beecrowd | 1050 DDD Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read an integer number that is the code number for phone dialing. Then, print the destination according to the following table: 61 - Brasilia 71 - Salvador 11 - Sao Paulo 21 - Rio de Janeiro 32 - Juiz de Fora 19 - Campinas 27 - Vitoria 31 - Belo Horizonte qualquer ddd digitado fora desse escopo, o resultado vai ter que ser "DDD nao cadastrado". If the input number isn’t found in the above table, the output must be: DDD nao cadastrado That means “DDD not found” in Portuguese language. Input The input consists in a unique integer number. Output Print the city name corresponding to the input DDD. Print DDD nao cadastrado if doesn't exist corresponding DDD to the typed number. Resolução: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int ddd = sc.nextInt(); String estado; if(ddd == 61) { estado = "Brasilia"; } else if(ddd == 71) { estado = "Salvador"; } else if(ddd == 11) { estado = "Sao Paulo"; } else if(ddd == 21) { estado = "Rio de Janeiro"; } else if(ddd == 32) { estado = "Juiz de Fora"; } else if(ddd == 19) { estado = "Campinas"; } else if(ddd == 27) { estado = "Vitoria"; } else if(ddd == 31) { estado = "Belo Horizonte"; } else { estado = "DDD nao cadastrado"; } System.out.println(estado); sc.close(); } }
  12. beecrowd | 1048 Salary Increase By Neilor Tonin, URI Brazil Timelimit: 1 The company ABC decided to give a salary increase to its employees, according to the following table: Salary Readjustment Rate 0 - 400.00 15% 400.01 - 800.00 12% 800.01 - 1200.00 10% 1200.01 - 2000.00 7% Above 2000.00 4% Read the employee's salary, calculate and print the new employee's salary, as well the money earned and the increase percentual obtained by the employee, with corresponding messages in Portuguese, as the below example. Input The input contains only a floating-point number, with 2 digits after the decimal point. Output Print 3 messages followed by the corresponding numbers (see example) informing the new salary, the among of money earned (both must be shown with 2 decimal places) and the percentual obtained by the employee. Note: Novo salario: means "New Salary" Reajuste ganho: means "Money earned" Em percentual: means "In percentage" Resolução: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); double salario, porcentagem, soma, percentual; salario = sc.nextDouble(); if(salario >= 0 && salario <= 400.0) { porcentagem = 15.0; } else if (salario > 400.0 && salario <= 800.0) { porcentagem = 12.0; } else if (salario > 800.0 && salario <= 1200.0) { porcentagem = 10.0; } else if (salario > 1200.0 && salario <= 2000.0) { porcentagem = 7.0; } else { porcentagem = 4.0; } percentual = (salario / 100.0) * porcentagem; soma = percentual + salario; System.out.printf("Novo salario: %.2f\n", soma); System.out.printf("Reajuste ganho: %.2f\n", percentual); System.out.printf("Em percentual: %.0f %%\n", porcentagem); sc.close(); } } Obs: para escrever o simbolo de %, utilizamos %%.
  13. beecrowd | 1047 Game Time with Minutes Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read the start time and end time of a game, in hours and minutes (initial hour, initial minute, final hour, final minute). Then print the duration of the game, knowing that the game can begin in a day and finish in another day, Obs.: With a maximum game time of 24 hours and the minimum game time of 1 minute. Input Four integer numbers representing the start and end time of the game. Output Print the duration of the game in hours and minutes, in this format: “O JOGO DUROU XXX HORA(S) E YYY MINUTO(S)” . Which means: the game lasted XXX hour(s) and YYY minutes. Resolução: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int hora1, minuto1, hora2, minuto2, inicio, fim, duracao, hora, minuto; hora1 = sc.nextInt(); minuto1 = sc.nextInt(); hora2 = sc.nextInt(); minuto2 = sc.nextInt(); /* Converter horas em minutos */ inicio = hora1 * 60 + minuto1; fim = hora2 * 60 + minuto2; if(inicio < fim) { duracao = fim - inicio; // subtração do fim pelo inicio do evento. } else { duracao = (60 * 24 - inicio) + fim; // multiplicar as horas por minuto e subtrair pelos minutos do inicio. } hora = duracao / 60; //converter minutos em horas minuto = duracao % 60; // sobra da conversao dos minutos para horas, a quais a sobra é considerada minuto. System.out.println("O JOGO DUROU " + hora + " HORA(S) E " + minuto + " MINUTO(S)"); sc.close(); } }
  14. beecrowd | 1046 Game Time Adapted by Neilor Tonin, URI Brazil Timelimit: 1 Read the start time and end time of a game, in hours. Then calculate the duration of the game, knowing that the game can begin in a day and finish in another day, with a maximum duration of 24 hours. The message must be printed in portuguese “O JOGO DUROU X HORA(S)” that means “THE GAME LASTED X HOUR(S)” Input Two integer numbers representing the start and end time of a game. Output Print the duration of the game as in the sample output. Resolução: import java.util.Scanner; import java.util.Locale; public class Main { public static void main(String[] args) { Locale.setDefault(Locale.US); Scanner sc = new Scanner(System.in); int inicio, fim, tempo; int dia1 = sc.nextInt(); int dia2 = sc.nextInt(); if(dia1 < dia2) { tempo = dia2 - dia1; } else { tempo = 24 - dia1 + dia2; } System.out.println("O JOGO DUROU " + tempo + " HORA(S)"); } }
  15. Ou você pode fazer como o Vinicius falou, ou você pode criar um outro array unidimensional para receber os números pares e os números impares. assim você conserva o array original.
×
×
  • Create New...