Question

c++ language Consider the series of numbers beginning at user-specified start and running up to but...

c++ language

Consider the series of numbers beginning at user-specified start and running up to but not including user-specified end, so for example start=1 and end=5 gives the series 1, 2, 3, 4. Return a new string[] array containing the string form of these numbers (e.g. "one", "two", "fifty-three" etc., except for multiples of 3, use "Fizz" instead of the number, for multiples of 5 use "Buzz", and for multiples of both 3 and 5 use "FizzBuzz".

Test with numbers from -10 to 110.

Write your string array to a file named YourNameFizzBuzz.txt - one value at a time

This project tests:

algorithm design

functions

arrays

strings

loops

conditionals

pseudocode / flowchart

user interface design

testing

strings

input validation

0 0
Add a comment Improve this question Transcribed image text
Answer #1


#include <iostream>
using namespace std;

int main(int argc, char const *argv[])
{
// declare variables
int Fizz = 3;
int Buzz = 5;
int end_num = 110;
int start_num=-10;
int FizzBuzz = Fizz * Buzz;
// ^ numbers divisible by 3 and 5 are also divisible by 3 * 5
cout<<"Enter Starting number: ";
cin>>start_num;
//checking if number withun range.
if ((start_num < -10) || (start_num >110))
{
cout<<"Entered Number is beyond range(-10 to 110) \n Enter Again:";
cin>>start_num;
}
cout<<"Enter the ending number: ";
cin>>end_num;
//validating input
if ((end_num < -10) || (end_num >110))
{
cout<<"Entered Number is beyond range(-10 to 110) \n Enter Again:";
cin>>end_num;
}

// start the loop, continue until it reaches end
// reaches the 'end'
for( start_num; start_num < end_num; start_num++)
{
if(start_num % FizzBuzz == 0) // divisible by 3 and 5
{
cout<<"FizzBuzz!!\n";
}
else if(start_num % Fizz == 0) // divisible by 3
{
cout<<"Fizz\n";
}
else if(start_num % Buzz == 0)// divisible by 5
{
cout<<"Buzz \n";
}
else // not divisible by 3 or 5
{
cout<<start_num<<endl;
}
}
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
c++ language Consider the series of numbers beginning at user-specified start and running up to but...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Python: Using your favorite text editor, write a program that outputs the string representation of numbers...

    Python: Using your favorite text editor, write a program that outputs the string representation of numbers from 1 to n. But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”. Submit by uploading a .py file Example: n = 15, Return: [ "1", "2", "Fizz", "4", "Buzz", "Fizz", "7", "8", "Fizz", "Buzz", "11", "Fizz", "13", "14", "FizzBuzz"...

  • HELLO EXPERTS, I need a code for this 4 questions.... it's make me crazy now... could...

    HELLO EXPERTS, I need a code for this 4 questions.... it's make me crazy now... could you guys help me please? it's java Given two strings, word and a separator sep, return a big string made of count occurrences of the word, separated by the separator string. repeatSeparator("Word", "X", 3)- "WordXWordXWord" repeatSeparator("This", "And", 2)- "ThisAndThis" repeatSeparator("This", "And", 1)- "This"| For example: Result Test System.out.println(repeatSeparator("Pa", "Tn", 4)); PaTnPaTnPaTnPa Consider the series of numbers beginning at start and running up to but...

  • C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...

    C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...

  • Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized...

    Part I Short Answer (50 points) 1. Write a pseudocode declaration for a String array initialized with the following strings: “Einstein”, “Newton”, “Copernicus”, and “Kepler”. 2. Assume names in an Integer array with 20 elements. Write a pseudocode algorithm a For Loop that displays each element of the array. 3. Assume the arrays numberArray1 and numberArray2 each have 100 elements. Write a pseudocode algorithm that copies the values in numberArray1 to numberArray2 . 4. Write a pseudocode algorithm for a...

  • Design a program in pseudocode that asks the user to enter a string containing a series...

    Design a program in pseudocode that asks the user to enter a string containing a series of ten single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string except for the highest value digit. You may only use one main module and one sorting function; otherwise, do not modularize your program. For example, if the user enters 5612286470, the sum would be 33. (0+1+2+2+4+5+6+6+7) If there are multiple highest...

  • Given below is a partially completed C program, which you will use as a start to...

    Given below is a partially completed C program, which you will use as a start to complete the given tasks. #define SIZE 9 #include <stdio.h> int compareAndCount (int[], int[]); double averageDifference (int[], int[]); void main() { } int compareAndCount(int arr1[SIZE], int arr2[SIZE]) { int count - @; for (int i = 0; i < SIZE; i++) { if (arri[i] > arr2[i]) count++; return count; Task 1: (10 pts) Show the design of the function compareAndCount() by writing a pseudocode. To...

  • JAVA Language public class ArraySkills { public static void main(String[] args) { // *********************** // For...

    JAVA Language public class ArraySkills { public static void main(String[] args) { // *********************** // For each item below you must code the solution. You may not use any of the // methods found in the Arrays class or the Collections classes // String[] myData; // 1. Instantiate the given array to hold 10 Strings. // 2. Add your name to the Array at index 0 and a friend's name to the Array at index 4 // 3. Move your...

  • Hey, I was wondering if there’s another way to make these methods not reliable to imports...

    Hey, I was wondering if there’s another way to make these methods not reliable to imports such as “import java.util.Arrays” and “import java.util.Hash” I am still new in coding and would like to know if there’s another way to do it! Here is the code! (Thank you in advance and I will really appreciate it :) ) /** This exercise involves implementing several methods. Stubs for each method with documentation are given here. It is your task to fill out...

  • Write a program that receives a series of numbers from the user and allows the user...

    Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average.   >>> totalSum =0 >>> count=0 >>> while True:    number=input("Enter a number or press enter to quit:")    if number =="":        break    totalSum += float(number)    count+=1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT