Skip to content

Instantly share code, notes, and snippets.

@samwx
Created May 29, 2015 22:17
Show Gist options
  • Save samwx/183c2bc6db9a62678b6e to your computer and use it in GitHub Desktop.
Save samwx/183c2bc6db9a62678b6e to your computer and use it in GitHub Desktop.
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @author Samuel Martins
*/
public class Multiplo {
public static void imprime(int[] vetor) {
for (int i = 0; i < vetor.length; i++) {
System.out.println(vetor[i] + " ");
}
}
public static void multiplo(int[] vetor) {
for (int i = 0; i < vetor.length; i++) {
if (((vetor[i] % 2) != 0) && ((vetor[i] % 5) >= 1) && ((vetor[i] % 7) == 0)) {
System.out.println(vetor[i] + " ");
}
}
}
public static void main(String args[]) {
int MIN, MAX;
int[] vetor;
Scanner scanner = new Scanner(System.in);
String[] integrantes = {"Samuel Martins", "Daniel Gregory", "Isabela Lima", "Frank Felipe", "Lilia Cardoso"};
System.out.println("Digite o número min:");
MIN = Integer.parseInt(scanner.nextLine());
System.out.println("Digite o número max:");
MAX = Integer.parseInt(scanner.nextLine());
vetor = new int[(MAX - MIN) + 1];
for (int i = 0; i < vetor.length; i++) //preenche vetor
{
if (i == 0) {
vetor[i] = MIN;
} else {
vetor[i] = vetor[i - 1] + 1;
}
}
for (String x : integrantes) {
System.out.println(x);
}
System.out.println("\n");
imprime(vetor);
System.out.println("\n");
multiplo(vetor);
System.out.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment