Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy won't my program print the countOfX values?
    primarykey
    data
    text
    <p>thanks for all your help in the last few q's! I think I've only got one issue remaining. For some reason it won't print the values of countOfX variables? As far as I can see it should work so there is obviously something im missing!</p> <p>hopefully somebody can point me in the right direction at least. Any help is greatly appreciated.</p> <pre><code>using System namespace Part1Skeleton { class FizzBuzz { int countOfFizz; int countOfBuzz; int countOfFizzBuzz; int countOfPrime; public static void Main() { int input = 1; //string enter; FizzBuzz fb = new FizzBuzz(); fb.BeginTesting(); while (input &lt;= 20) { //Console.WriteLine("Please enter a number: "); //enter = Console.ReadLine(); //input = int.Parse(enter); fb.BeginTesting(); fb.IsFizz(input); fb.IsBuzz(input); fb.IsFizzBuzz(input); fb.IsPrime(input); input++; } fb.TotalFizz(); fb.TotalBuzz(); fb.TotalFizzBuzz(); fb.TotalPrime(); } public bool IsFizz(int input) { if (input % 9 == 0 &amp;&amp; input != 0) { Console.WriteLine("Fizz"); countOfFizz++; return true; } return false; } public bool IsBuzz(int input) { if (input % 13 == 0 &amp;&amp; input != 0) { Console.WriteLine("Buzz"); countOfBuzz++; return true; } return false; } public bool IsFizzBuzz(int input) { if (input % 9 == 0 &amp;&amp; input % 13 == 0 &amp;&amp; input != 0) { Console.WriteLine("FizzBuzz"); countOfFizzBuzz++; return true; } return false; } public bool IsPrime(int input) { if (input == 0 || input == 1) { Console.WriteLine(input); return false; } else if (input % 9 == 0 || input % 13 == 0) { return false; } else { for (int i = 2; i &lt; input; i++) { if (input % i == 0 &amp;&amp; i != input) { Console.WriteLine(input); return false; } } } Console.WriteLine("Prime"); countOfPrime++; return true; } public void BeginTesting() { countOfFizz = 0; countOfBuzz = 0; countOfFizzBuzz = 0; countOfPrime = 0; } public int TotalFizz() { Console.WriteLine("Number of Fizz: "); Console.Write(countOfFizz); return countOfFizz; } public int TotalBuzz() { Console.WriteLine("Number of Buzz: "); Console.Write(countOfBuzz); return countOfBuzz; } public int TotalFizzBuzz() { Console.WriteLine("Number of FizzBuzz: "); Console.Write(countOfFizzBuzz); return countOfFizzBuzz; } public int TotalPrime() { Console.WriteLine("Number of Prime: "); Console.Write(countOfPrime); return countOfPrime; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload