java multiplo.java

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java multiplo.java相关的知识,希望对你有一定的参考价值。

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();


    }

}

以上是关于java multiplo.java的主要内容,如果未能解决你的问题,请参考以下文章

Java Math

Java 布尔运算

java [Java] Java常用代码#java

Java - 35 Java 实例

Java While 循环

Java 字符串