The work has not been graded but I like the output that was submitted to me. Is it possible for the same prof to do the next assignment I will be submitting? If possible, I will greatly appreciate it.
I can’t seem to figure out why there is no input asked when an invalid number is asked for. The code I have so far is below:
int main()
{
cout << “Please enter your numbers: “; // Output to user
string st; // Initialize Variable
cin >> st;// Input numbers
stringstream stream(st); // String stream
int arr[50]; // Max array
int count = 0; // Initialize variable
int number;
while (stream >> number) // While loop
{
arr[count] = number; // Array
count++; // Increment count
if (stream.peek() == ‘,’)
stream.ignore(); // Checks for comma and ignores them
}
for (int i = 0; i < count; i++) // For Loop
{
number = arr[i]; // Number into array
{
if ((number %3 == 0) && (number %5 == 0)) // Checks if the number is divisible by 3 or 5
{
cout << “Number: ” << number << ” – FizzBuzz” << endl; // Output ” – FizzBuzz” if divisible by 3 or 5
}
else if (number % 3 == 0) // Checks if the number is divisible by 3
{
cout << “Number: ” << number << ” – Fizz” << endl; // Output ” – Fizz” if divisible by 3
}
else if (number % 5 == 0) // Checks if the number is divisible by 5
{
cout << “Number: ” << number << ” – Buzz” << endl; // Output ” – Buzz” if divisible by 5
}
else
{
cout << number << ” is NOT divisible by either 3 or 5.” << endl; // Output if number not divisible by 5
cout << “Please enter another number: “; // Output asking for another number
cin >> number; // Input for new number
break;
}
}
}
return 0;
}
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more