Connect with knowledgeable experts and enthusiasts on IDNLearn.com. Find the solutions you need quickly and accurately with help from our knowledgeable community.
Sagot :
Answer:
public class Main
{
// required method
public static void fizzBuzz(){
// looping through 1 to 100
for(int i = 1; i <= 100; i++){
//if number is evenly divisible by both 3 and 5
if(i%3 == 0 && i%5 == 0){
System.out.println("fiz buzz");
}
// if number is divisible by 3
else if (i%3 == 0){
System.out.println("fizz");
}
// if number is divisible by 5
else if (i%5 == 0){
System.out.println("buzz");
}
// if number is not divisible by both 3 and 5
else {
System.out.println(i);
}
}
}
// main method
public static void main(String[] args) {
//calling function
fizzBuzz();
}
}
Explanation:
Your participation means a lot to us. Keep sharing information and solutions. This community grows thanks to the amazing contributions from members like you. Your search for solutions ends at IDNLearn.com. Thank you for visiting, and we look forward to helping you again.