Java if statement Question 1

Question

We would like to output HiFive if the number is a multiple of 5.

Output HiEven if the number is a multiple of 2.

import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println("Enter an integer: ");
    int number = input.nextInt();

    //your code/*from  ww  w .j  a v a  2 s  .co m*/
  }
}


import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println("Enter an integer: ");
    int number = input.nextInt();

    if (number % 5 == 0)
      System.out.println("HiFive");

    if (number % 2 == 0)
      System.out.println("HiEven");
  }
}



PreviousNext

Related