Ask Question
18 December, 13:01

How to print:

Number is equal to: 1 and it is odd number

Number is equal to: 2 and it is even number

Number is equal to: 3 and it is odd number

Number is equal to: 4 and it is even number

in the console using java

using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens

+2
Answers (1)
  1. 18 December, 15:27
    0
    Here is a possible solution:

    int number = 1;

    while (number < = 4) {

    String kind;

    if ((number % 2) = = 1) {

    kind = "odd";

    }

    else {

    kind = "even";

    }

    String output = String. format ("Number is equal to: %d and it is %s number/n", number, kind);

    System. out. print (output);

    number++;

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “How to print: Number is equal to: 1 and it is odd number Number is equal to: 2 and it is even number Number is equal to: 3 and it is odd ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers