Question
java programming. hint: please use if-else method.
Need to print numbers 1..100 For multiples of 3, print Fizz instead of the number For multiples of 5. print Buzz instead
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Source Program:

import java.io.*;
public class Main
{
   public static void main(String[] args) {
   int i=1;
   for(i=1;i<=100;i++)
   {
   if(i%3==0 && i%5==0)
System.out.println("FizzBuzz");
   else if(i%3==0)
   System.out.println("Fizz");
   else if(i%5==0)
   System.out.println("Buzz");
   else
   System.out.println(i);
  
   }
   }
}

1 import java.io.*; 2 public class Main - 3 - { public static void main(String[] args) { int i=1; for(i=1;i<=100;i++) if(i%3=

Sample Output:

Fizz Buzz Fizz Fizz Buzz Fizz 14 FizzBuzz 16 17 Fizz 19 Buzz Fizz 22 23 Fizz Buzz 26 Fizz FizzBuzz

31 Fizz 34 Buzz Fizz 37 38 Fizz Buzz 41 Fizz 43 44 FizzBuzz 46 47 Fizz 49 Buzz Fizz 52 53 Fizz Buzz 56 Fizz 58 59 FizzBuzz

61 Fizz 64 Buzz Fizz 68 Fizz Buzz 71 Fizz 73 74 FizzBuzz 76 77 Fizz 79 Buzz Fizz 82 83 Fizz Buzz 86 Fizz 88 89 FizzBuzz

92 Fizz Buzz Fizz 97 98 Fizz Buzz

Add a comment
Know the answer?
Add Answer to:
java programming. hint: please use if-else method. Need to print numbers 1..100 For multiples of 3,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program that prints the numbers from 1 to 100. But for multiples of...

    Write a C program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

  • Write a program that prints the numbers from 1 to 100. But for multiples of three...

    Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. Hints: You can use a for loop with a range to simplify the iteration Use the modulo division operator (%) to find the remainder of a division calculation

  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • HELLO EXPERTS, I need a code for this 4 questions.... it's make me crazy now... could...

    HELLO EXPERTS, I need a code for this 4 questions.... it's make me crazy now... could you guys help me please? it's java Given two strings, word and a separator sep, return a big string made of count occurrences of the word, separated by the separator string. repeatSeparator("Word", "X", 3)- "WordXWordXWord" repeatSeparator("This", "And", 2)- "ThisAndThis" repeatSeparator("This", "And", 1)- "This"| For example: Result Test System.out.println(repeatSeparator("Pa", "Tn", 4)); PaTnPaTnPaTnPa Consider the series of numbers beginning at start and running up to but...

  • c++ language Consider the series of numbers beginning at user-specified start and running up to but...

    c++ language Consider the series of numbers beginning at user-specified start and running up to but not including user-specified end, so for example start=1 and end=5 gives the series 1, 2, 3, 4. Return a new string[] array containing the string form of these numbers (e.g. "one", "two", "fifty-three" etc., except for multiples of 3, use "Fizz" instead of the number, for multiples of 5 use "Buzz", and for multiples of both 3 and 5 use "FizzBuzz". Test with numbers...

  • LANGUAGE C++ I need help with all 3 questions. Thank you in advance Password Generator← 10...

    LANGUAGE C++ I need help with all 3 questions. Thank you in advance Password Generator← 10 10.201.51. eRAD D scheduling山UitPro 6 Fizz Buzz Write a function "void FizzBuzz(int n)" that lists all of the numbers from 1 to n, but replace all numbers divisible by 3 but not divizible by 5 with the word "Fizz", replace all numbers divisible by 5 but not divisible by 3 with the word "Buzz", and replace all numbers divisible by both 3 and 5...

  • (1) Read in a number from the user that is in the ranger 1-200. If the...

    (1) Read in a number from the user that is in the ranger 1-200. If the user inputs a number out of that range, print out:Invalid number, try again. and read in a number until a valid one is produced. (2) Print out the numbers from 1 to userInput but: If a number is divisible by 3, print Fizz instead If a number is divisible by 5, print Buzz instead If a number is divisible by both 3 and 5,...

  • Write a C program that prints the numbers from 1 to 100, but substitutes the word...

    Write a C program that prints the numbers from 1 to 100, but substitutes the word “fizz” if the number is evenly divisble by 3, and “buzz” if the number is divisible by 5, and if divisible by both prints “fizz buzz” like this: 1 2 fizz 4 buzz fizz 7 8 fizz buzz 11 fizz 13 14 fizz buzz 16 17 fizz 19 buzz ... and so on

  • Java Programming. Write your own source code with comments. (Print distinct numbers) Write a program that...

    Java Programming. Write your own source code with comments. (Print distinct numbers) Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exactly one space (i.e., if a number appears multiple times, it is displayed only once). (Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.) After the input, the array contains the distinct...

  • Programming in Java. Please attached the screenshot of source code and the output Thanks. Java Programming:...

    Programming in Java. Please attached the screenshot of source code and the output Thanks. Java Programming: A Comprehensive Introductia See this solution in the app :3 Chapter 3, Problem 17E Bookmark Show all steps: 0 ON Problem Write a program that uses a loop to print a list of 100 numbers consisting of alternating 1's and -1's, starting with 1.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT