Question:
PLEASE HELP java loops and conditions (if else)?
2008-04-30 03:16:49 UTC
Write a program that asks for a number to be entered. The program checks
whether the number is
• an even number, i.e., if the number is divided by 2 there is no remainder.
• divisible by 3, i.e., if the number is divided by 3 there is no remainder
• divisible by 4.

If the number is an even number, the program prints the following message
“You have entered an EVEN number”

If the number is divisible by 3, the program prints the following message
“You have entered a multiple of 3”

If the number is divisible by 4, the program prints the following message
“You have entered a multiple of 4”

The program always ends by printing the number that was entered.
Three answers:
Is that how it is?
2008-04-30 03:24:13 UTC
Source code or it didn't happen.
?
2016-10-06 13:53:50 UTC
Huh? You in no way as much as date the score variable. If it grew to become into between 0 and one hundred before everything, then it fairly is nonetheless going to be between 0 and one hundred while the loop concern is checked returned, and returned, and returned... in case you basically want the entire ingredient to run as quickly as, then could I ask why you're utilising a loop interior the 1st place? the only purpose of a loop is to do something different situations.
venkatesh
2008-04-30 03:34:34 UTC
Take a input let us assume 10



int a=10;

if(a%2==0)

{

System.out.printline("You have entered an EVEN number");

}



if(a%3==0)

{

System.out.printline("You have entered a multiple of 3");

}



if(a%4==0)

{

System.out.printline("You have entered a multiple of 4");

}


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...