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

a C++ program using pointers plz Write a program that will create dynamically al

ID: 644946 • Letter: A

Question

a C++ program using pointers plz

Write a program that will create dynamically allocated array of monthly sales figures whose size has been input by the user. After prompting the user to input the sales figure, It will find the highest monthly sales amount and the lowest monthly sales amount. And it will calculate the average sales of the monthly figures. The program should be modular with each major task being handled by its own function. Sample Run Please input the number of monthly sales figures to be input: 4 Please input the sales for month 1: 1290.89 Please input the sales for month 2: 905.95 Please input the sales for month 3: 1567.98 Please input the sales for month 4: 994.83 The highest monthly sales amount was $ 1567 The lowest monthly sales amount was $ 994.95 The Average sales amount for 4 sales figures: 1189.91

Explanation / Answer

#include <iostream>
#include <new>
using namespace std;

int main()
{
int size,max=0,min,sum=0,num;

cout << "Class size: ";
cin >> size;
  
int* array = new int[size]; //Dynamically allocated "array" of size 'size'

for(int i = 0; i < size; i++)
{
cout<<"PLease input the sales for month"<<i+1<<" ";
cin>>num;
array[i]=num;
sum = sum+num;
if(max<num){
max=num;
}
if(min>num){
min=num;
}
}
cout<<"min is :"<<min<<" ";
cout<<"max is :"<<max<<" ";
cout<<"Avg is :"<<sum/size<<" ";
delete [] array;

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote