Learning Java, Help Please
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Learning Java, Help Please

  1. #1
    Join Date
    Aug 2011

    Red face Learning Java, Help Please

    Hi guys,

    I am learning Java, but I am stuck at the beginning making Fizz Buzz. My teacher suggested that we try it on our own and I am stuck.

    "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”. For numbers which are multiples of both three and five print “FizzBuzz”."

    If I could get some help I would really appreciate it.


  2. #2
    Join Date
    May 2009

    Re: Learning Java, Help Please

    Let's say you can write a progran that prints the integers between 1 and 100.

    Now to check whether an integer i is a multiple if 3 you can use the modulo operator % like,

    if (i%3 == 0) {
    // Fizz

    You can check for multiples of 5 analogously. And to check whether both 3 and 5 multiplicity apply you can combine the tests for each using the and operator &&.
    Last edited by nuzzle; August 5th, 2011 at 12:55 AM.

  3. #3
    Join Date
    Mar 2010
    Melbourne Australia

    Re: Learning Java, Help Please

    Everything you need to learn java is right here


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)