Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The first picture is the requirements for program. The second picture is the details of the requirements. The third and forth pictures are comments given

image text in transcribed

The first picture is the requirements for program.

image text in transcribed

The second picture is the details of the requirements.

image text in transcribed

image text in transcribed

The third and forth pictures are comments given by instructor. Using C++ please

You're responsible for writing two functions and testing them: fizzbuzz fizzbuzz2 Fizzbuzz is a function that will take a number between 1 and 100, and will return a string containing one of four values based on which case it is: Case 1) "Fizz" if the number passed in is divisible by 3 (for example, 12). Case 2) "Buzz" if the number passed in is divisible by 5 (for example, 20). Case 3) "Fizzbuzz" if the number passed in is divisible by both 3 and 5 (for example 30). .. . . Case 4) "" otherwise., (for example, passing in 7 will return *7"). This is a string, not an int. To convert from an int to a string in C++, use the to_string() function. For example, to_string(2) returns "2". Fizzbuzz2 is exactly the same, but with one additional check. Prior to Case 4, you must add the digits of the number together, and apply the same checks to the sum. In other words, if you pass in 41, you will return "Buzz" because even though 41 isn't divisble by 3 or 5, 4+1 = 5. You will add this check after Case 3 and before Case 4. You must write a series of tests for your code to verify that your code is working properly. I recommend starting with the simplest tests possible, and writing as little code as possible to answer those tests, and continuing to go back and forth until you can't think of anything else to test. Use "make" to compile this code, rather than trying to compile it manually. For this assignment, you must log on to the server and go into the ~/fizzbuzz_tdd directory. You must implement 4 things for 100% on this assignment: 1) You must write a fizzbuzz function that takes in an int and returns a string according to the rules for fizzbuzz (found in the README file). 2) You must write a fizzbuzz2 function that functions just like fizzbuzz, but between Case 3 and Case 4 adds another check where it adds the two digits of the number together, and if they are divisible by 3, returns "Fizz", divisible by 5 returns "Buzz" and if it is divisible by both returns "Fizzbuzz"; 3) Write test cases for them, to guarantee your implementation is correct. 4) Inside of main, write a loop that prints the results of fizzbuzz() and fizzbuzz2() from 1 to 100. If you ever forget where you need to write code, I've helpfully put comments with "YOU:" in main.cc at each place you need to write code. chude using namespace std; YOU: Write fiz buzz Return "Fizz" X 15 divisible by 3 Return "Buzz 11x is divisible by S // Return "Fizzbuzz" if x is divisible by both 3 and 5 // Return a string containing the number otherwise /Return "Error" 1 x is less than 1 or greater than 100 string fizzbuzz (int x) //This won't compile, since it's not returning anything 1/YOU: Write tests to test your fizzbuzz implementation TEST (Fizzbuzz, GoodTests) EXPECT EQ(fizzbuzz (33). "Fizz"); EXPECT_EQ(fizzbuzz (50), "Buzz"); EXPECT EQ(fizzbuzz (13). "13"): EXPECT EQ (fizzbuzz (45), "Fizzbuzz"); EXPECT_EQ(fizzbuzz (42). "Fizz"): //YOU: Write your own tests to check bad inputs here TEST (Fizzbuzz, BadTests) //YOU: Write your own tests to check edge inputs here J //YOU: Now write a function called fizzbuzz2, that is exactly the same as fizzbuzz, but with one important change, Before returning a number, add the digits of the number together, and use the result from that sum with the same ules. For example, 23 would return "Buzz" because 2+3 = 5. string fizzbuzz2(int x) return ; 1/YOU: Now write good, bad, and edge cases for fiz buzz2 as well. int main(int arge, char * argv) testing::InitGoogleTest (Gargc, argv); Sifndef Foo 1/Stop people from compiling this code using 'compile' static assert(false, "type make to build this, not compile fendit cout

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mastering Apache Cassandra 3 X An Expert Guide To Improving Database Scalability And Availability Without Compromising Performance

Authors: Aaron Ploetz ,Tejaswi Malepati ,Nishant Neeraj

3rd Edition

1789131499, 978-1789131499

More Books

Students also viewed these Databases questions

Question

What does read command do in previous exercise

Answered: 1 week ago

Question

=+3. How serious of a response is warranted to this situation?

Answered: 1 week ago

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago

Question

What is loss of bone density and strength as ?

Answered: 1 week ago

Question

Persuading Your Audience Strategies for

Answered: 1 week ago