Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Tarefas_4;
- public class EX_05
- {
- public static void main(String[] args)
- {
- // Vetor
- int vetor [] = popular_vetor();
- // Chamada de funcoes
- relatorio(vetor);
- conserta_vetor(vetor);
- relatorio(vetor);
- }
- private static int[] popular_vetor()
- {
- int vet [] = new int[25];
- for (int i = 0; i < vet.length; i++)
- {
- vet[i] = i - 10;
- }
- return vet;
- }
- private static void relatorio(int[] vet)
- {
- System.out.print("\n------------------------------------------------");
- for (int i = 0; i < vet.length; i++)
- {
- System.out.printf("\n Indice [%d]: %d", i+1, vet[i]);
- }
- System.out.println("\n------------------------------------------------");
- }
- private static int [] conserta_vetor(int[] vet)
- {
- for (int i = 0; i < vet.length; i++)
- {
- if (vet[i] < 0)
- {
- vet[i] = 0;
- }
- }
- return vet;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement