Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please I need help with this program. I am writing in C++. Thank you in advance.

ID: 3808523 • Letter: P

Question

Please I need help with this program. I am writing in C++. Thank you in advance.

Write a program that works with two arrays of the same size that are related to each other in some way (or parallel arrays). Your two arrays must be of different data types. For example, one array can hold values that are used in a formula that produces the contents of the second array. Some examples might be: from a previous program, populations and the associated flowrates for those populations (an int array of populations and a double array of the associated flowrate) a series of values and the squareroot s of those integers (an int array of values and a double array of associated squareroot s) a series of values and an indication of whether or not each value is odd or even (an int array and a bool array) Declare and initialize a constant to represent the size of both arrays (at least 10 positions) Declare and initialize your first array Declare and initialize your second array, based on the data in your first array Output the contents of both arrays in neat columns with headers Optional suggestions (good to do, not required) Try to break your program up into different functions Use user input to initialize the first array

Explanation / Answer

#include<iostream>
using namespace std;
class ArrayExample
{
   int size=10,iloop;
   int* arr1=new int[size];   //create integer array of 10 elements
   double* arr2 = new double[size];   //create double array of 10 elements

  
   public:
   void init()
   {
       cout<<"Enter The Array of 10 Numbers"<<endl;
       for(iloop=0;iloop<size;iloop++)
       {
           cout<<"Enter The Whole Number:"<<endl;
           cin>>arr1[iloop];   //input through user
       }
   }  
   void createarr2()
   {
       for(iloop=0;iloop<size;iloop++)
       {
           arr2[iloop]=arr1[iloop]*arr1[iloop];   //store square of arr1 in arr2
       }
   }
   void printarray()
   {
       cout<<"Array1   Array2(its square)"<<endl;
       for(iloop=0;iloop<size;iloop++)
       {
           cout<<arr1[iloop]<<" "<<arr2[iloop]<<endl;   //prints array in columns format
       }
   }
};//end of class
int main(void)
{
   ArrayExample a;   //create object a
   a.init();   //initialize the 1st array
   a.createarr2();   //initialize the second array
   a.printarray();   //prints both the array
   return 1;
}//end of main

/***********OUTPUT************
Enter The Array of 10 Numbers
Enter The Whole Number:
2
Enter The Whole Number:
3
Enter The Whole Number:
4
Enter The Whole Number:
5
Enter The Whole Number:
6
Enter The Whole Number:
7
Enter The Whole Number:
8
Enter The Whole Number:
9
Enter The Whole Number:
10
Enter The Whole Number:
11
Array1          Array2(its square)
2               4
3               9
4               16
5               25
6               36
7               49
8               64
9               81
10              100
11              121

*****************************/
//plz let me know was it the same u wanted..?