FizzBuzz Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Burks90
    New Member
    • Oct 2013
    • 1

    FizzBuzz Question

    Hi,

    I'm new to C# and won't lie, I'm finding it rather hard after not coding for a couple of years (previous experience being Python and HTML). My first assignment for the Computer Science degree I've just embarked upon is FizzBuzz which although is generally easy as it would appear with a google, it's also got some extra bools and intergers thrown in which I'm not entirely sure what to do with.

    If anybody can point me in the right direction with my code it'd be greatly appreciated.

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    {
    
    namespace Fizzbuzz
      {
        class Program
     
            static void Main(string[] args)
            {
                for (int i = 1; i <= 100; i++)
            
                
                     if (i % 3 == 0) Console.Write("Fizz");
                     if (i % 5 == 0) Console.Write("Buzz");
                     if (Console.CursorLeft == 0) Console.Write(i);
    
        if (i)
        {   
            public bool IsFizz(int input); 
            public bool IsBuzz(int input); 
            public bool IsFizzBuzz(int input); 
            public bool IsPrime(int input);
        } 
        {       
            public void BeginTesting() 
            public int TotalFizz()
            public int TotalBuzz()
            public int TotalFizzBuzz()
            public int TotalPrime()
        }
                    Console.WriteLine();
                
                Console.ReadLine();         
            }
      }
    }
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    There seem to be a lot of errors that I can see in the code. In fact, your code does not compile in my VS 2008 environment.

    If you have posted a code fragment then I would suggest you post in separate code tags so that we can look at individual questions, one at a time.

    If this is your complete code, then there are a lot of things to take care of before it will compile. I would suggest starting with this code as a base (note the curly brace placement):

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
     
    namespace Fizzbuzz  
    {
        class Program
        {     
            static void Main(string[] args)
            {
                for (int i = 1; i <= 100; i++)
                {
                    if (i % 3 == 0) Console.Write("Fizz");
                    if (i % 5 == 0) Console.Write("Buzz");
                    if (Console.CursorLeft == 0) Console.Write(i);
                }
            }
        }
    }
    From here, tackle a single goal at a time and don't move on until you have completed your goal and your code compiles without error. The last thing you want are compounding errors, especially when learning a new environment/language/etc.

    Give us some more information and we would be happy to help.

    Comment

    Working...