I am trying to complete this assignment where if an integer is divisible by 2,3, and 7, it replaces the following numbers (25-50) with "BuzzLightYear"
I have the numbers listed correctly, but when I run the program it prints the text along with the number when I just want the text instead of the number.
Here is my code:
int variable = 25;
while (variable <= 50)
{
Console.WriteLine(variable + "\n");
++variable;
if (variable % 2 == 0 && variable % 3 == 0 && variable % 7 == 0)
{
Console.Write("BuzzLightYear");
}
}
Console.ReadKey();
Aucun commentaire:
Enregistrer un commentaire