Ask 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 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

+1
Answers (1)
  1. 1 June, 01:46
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers