the updateDatatxt is as follows 23 56 140 19 65 77 87 109 24
the updateData.txt is as follows:
23 56 140 19 65 77 87 109 244 36 87 22 -61 10 987
I am struggling with the whole project..
CS 200- Exam 2 Name Overview This project will evaluate your ability to create and use functions and arrays. In addition, you will be required to use files for input and output. One: isDivisible function Create a function named isDiviaible with the following function declaration: bool isDivisible (int number, int divisor) //PRECONDITION: number can be any integer, divisor must be greater than o / /POSTCONDITION: Wil1 return true if number is evenly divisible by the 1. divisor (the remainder is zero. Otherwise returns false. 2. Test your code by calling it from the main function. test. This code can be deleted after you are finished with your Part Two: Create an array 1. Create an array populated with the integer values 1 through 20. Part Three: checkDivisibleBy3 method 1. Create a function called checkDivisibleBy3. 2. This function will receive as a parameter an array of integers 3. Using theisDivisible function created in Part One, count how many of the elements in the array are 4. 5. divisible by 3. Display the count with a message like: \"There were 6 elements that were divisible by 3\". Call this function from the main function using the array you created in Part Two. Part Four: 1. Create a function called updateArray which will change the values in an array using the values in the file named \"updateData.txt\". This file is available for download in D2L. 2. If the file has fewer values than the array size, leave the remaining array elements with their original values. 3. Call this function from the main function using the array you created in Part Two. Part Five: 1. Create a function called divideBy7 which will display the quotient for each element in the array when divided by 7. [Remember the issue with integer division.] 2. Display each answer with 2 decimal places. 3. Each answer should be in a column which is 10 characters wide. 4. There should be only five (5) answers per line of output. That is, you will need to insert a newline character ates, you will need to insert a newline character 5. 6. after every 5 answers Write this output to an output named \"quotienta.txt\" Call this function from the main function using the updated array from Part Four Solution
#include <iostream>
#include <cmath>
using namespace std;
bool is_integer(float k)
{
return std::floor(k) == k;
}
bool isDivisible(int number, int divisor)
{
if(is_integer(number) && divisor > 0)
{
if(number % divisor == 0)
{
return true;
}
return false;
}
}
template <typename T, int N>
void checkDivisibleby3(T (&array)[N])
{
int count=0;
for(int i=0;i<N;i++)
{
if(isDivisible(array[i],3))
{
count+=1;
}
}
cout<<\"There were \"<<count<<\" elements that were divisible by 3\"<<endl;
}
int array[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20}
checkDivisibleby3(array);

