Ask Question
1 July, 07:42

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

+3
Answers (1)
  1. 1 July, 08:31
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers