Question

In: Computer Science

with C# FizzBuzz is a group word game for children to teach them about division. Players...

with C# FizzBuzz is a group word game for children to teach them about division. Players take turns to count incrementally, replacing any number divisible by three with the word fizz, any number divisible by five with the word buzz, and any number divisible by both with fizzbuzz.

Some interviewers give applicants simple FizzBuzz-style problems to solve during interviews. Most good programmers should be able to write out on paper or whiteboard a program to output a simulated FizzBuzz game in under a couple of minutes.

Create a console application that outputs a simulated FizzBuzz game counting up to 100. The output should look something like this:

1, 2, Fizz, 4, Buzz, Fizz, 7, 8, Fizz, Buzz, 11, Fizz, 13, 14, FizzBuzz,
16, 17, Fizz, 19, Buzz, Fizz, 22, 23, Fizz, Buzz, 26, Fizz, 28, 29, FizzBuzz, 31,
32, 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,
62, Fizz, 64, Buzz, Fizz, 67, 68, Fizz, Buzz, 71, Fizz, 73, 74, FizzBuzz, 76,
77, Fizz, 79, Buzz, Fizz, 82, 83, Fizz, Buzz, 86, Fizz, 88, 89, FizzBuzz, 91,
92, Fizz, 94, Buzz, Fizz, 97, 98, Fizz, Buzz.

Solutions

Expert Solution

using System;

class GFG{

   

// Driver Code

public static void Main()

{

    int n = 100;

    // Loop for 100 times

    for(int i = 1; i <= n; i++)                            

    {

         

        // Number divisible by 15(

        // divisible by both 3 & 5),

        // print 'FizzBuzz' in place

        // of the number

        if (i % 15 == 0)

            Console.Write("FizzBuzz" + " ");

        // Number divisible by 3,

        // print 'Fizz' in place

        // of the number

        else if (i % 3 == 0)    

            Console.Write("Fizz" + " ");

        // Number divisible by

        // 5, print 'Buzz'

        // in place of the number

        else if (i % 5 == 0)                                            

            Console.Write("Buzz" + " ");

         

        // Print the numbers

        else

            Console.Write(i + " ");                    

    }

}

}


Related Solutions

C++ PLEASE In the children’s game, Duck, Duck, Goose, a group of children sit in a...
C++ PLEASE In the children’s game, Duck, Duck, Goose, a group of children sit in a circle. One of them is elected “it” and that person walks around the outside of the circle. The person who is “it” pats each child on the head, saying “Duck” each time, until randomly reaching a child that the “it” person identifies as “Goose.” At this point there is a mad scramble, as the “Goose” and the “it” person race around the circle. Whoever...
There are three basketball players, A, B, and C. A takes 30 shots a game, with...
There are three basketball players, A, B, and C. A takes 30 shots a game, with a shooting percentage of 70%. B takes 20 shots, hitting 60%, and C takes 10 shots, hitting 50%. write a program in java or Python. Use the above statement to simulate players A, B, and C in a season of 82 games. Generate a string of shots for each player in each game, length 30, 20, and 10 shots. Count the number of shots...
____________________________________________________________________ Group 2: While you are at your son's baseball game, one of the other players...
____________________________________________________________________ Group 2: While you are at your son's baseball game, one of the other players slides into second base and then lies there without moving. Another player yells for help. The other parents know you are a nurse and ask you to check on the player while they call 911. When you approach the child, you note that his leg is fractured and lying in an awkward position. You feel that if you reposition the leg, you might cause...
Look online- find a website that inspires you to teach children about math and science. Post...
Look online- find a website that inspires you to teach children about math and science. Post the URL address in your response and then tell us what kind of activities this site inspires. What would be one activity you would do with young children to support their math and/or science development?
C program with functions Make a dice game with the following characteristics: must be two players...
C program with functions Make a dice game with the following characteristics: must be two players with two dice. when player 1 rolls the marker is annotated when player 2 rolls the marker is annotated in other words, for each roll the added scores must be shown. Example: Round 1: player 1 score = 6 player 2 score = 8 Round 2: player 1 score = 14 player 2 score = 20 Whoever reaches 35 points first wins. if a...
I am using C++ Write a program that allows two players to play a game of...
I am using C++ Write a program that allows two players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an asterisk (*). The program should run a loop that does the following: Displays the contents of the board array. Allows player 1 to select a location on the board for an X. The program should ask the user...
This question is about the sequential moves Stag Hunt game. There are two players. Player 1...
This question is about the sequential moves Stag Hunt game. There are two players. Player 1 moves first, player 2 observes player 1’s move, and then player 2 moves. Players get 10 jollies each if they both choose Stag; 5 jollies if they choose Hare; and 0 jollies if they choose Stag but the other player does not. What is the set of (pure) strategies for player 1? What is the set of (pure) strategies for player 2? Explain why...
Solve the follwing game theory matrix, Find the optimal strategies for both players a b c...
Solve the follwing game theory matrix, Find the optimal strategies for both players a b c A -4 2 3 B -1 0 4 C 2 -1 -3
C++ Make a Tic Tac Toe game for 2 players to play using 2D arrays and...
C++ Make a Tic Tac Toe game for 2 players to play using 2D arrays and classes. Do not add more #include functions other than the ones listed. I never said what type of code I needed in a previous question. I apologize and I can't go back and change it so here is the same question with more information Using the tictactoeGame class, write a main program that uses a tictactoeGame to implement a game in which two players...
9)Attley Inc. has three separate divisions: Division A, Division B, and Division C. Information about the...
9)Attley Inc. has three separate divisions: Division A, Division B, and Division C. Information about the three divisions follows: Division A Division B Division C Operating income $ 26,750 $121,000 $22,400 Average operating assets $250,000 $412,000 $83,000 The company has recently implemented a new performance evaluation system. Based on this new system, a division manager would only receive a bonus if the ROI of the division was greater than 25% and residual income was in excess of $20,000. If management...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT