At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Discover a wealth of knowledge from experts across different disciplines on our comprehensive Q&A platform. Connect with a community of professionals ready to provide precise solutions to your questions quickly and accurately.
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:
Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.