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

You are required to write an interactive C ++ program which prompts the user for

ID: 671755 • Letter: Y

Question

You are required to write an interactive C ++ program which prompts the user for seven (7) real numbers and performs the following tasks:

Stores the numbers which reads interactively into one dimensional array, A.

Calculates the sum, and the average of the numbers.

Finds the smallest value of the numbers.

Finds the largest value of the numbers.

Prints all the results with proper headings.

Program requirements:

-     You must submit a structure chart indicating the pictorial solution with all functions and main.

-     The program must contain at least five functions using necessary parameters. These functions should read the data, perform the above tasks, and print the results.

-     The program should include a class and an object.

-     The program must be fully documented.

-    You must submit a hard copy of the source and a properly labeled output.

-     You should submit a digital copy of source code.

-     Test your program for different values using real numbers.

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#define s 20
class array
{
private:
int I,a[s];
public:
void enter(int);
void min(int);
void max(int);
void sum(int);

void avg(float);
};
void array::enter(int n)
{
for(I=0;I<n;I++)
cin>>a[I];
}
void array::display(int n)
{
for(I=0;I<n;I++)
cout<<a[I]<<" ";
}
void array::min(int n)
{
int minimum=a[0];
for(I=1;i<n;i++)
if(a[I]<minimum)
minimum=a[I];
cout<<" Smallest No= "<<minimum;
}
void array::max(int n)
{
int maximum=a[0];
for(I=1;i<n;i++)
if(a[I]>maximum)
maximum=a[I];
cout<<" Largest No= "<<maximum;
}
void array::sum(int n)
{
int total=0;
for(I=0;i<n;i++)
total+=a[I];
cout<<" Sum= "<<total;
}

void array::avg(flaot)
{
avg=Sum/n;

cout<<" average= "<<avg;
}
void main()
{
array obj;
int n;
clrscr();
cout<<" Enter the number of elements in the array <= "<<s<<endl;
cin>>n;
cout<<" Enter "<<n<<" elements: ";
obj.enter(n);
cout<<" Given array is: ";
obj.display(n);
obj.min(n);
obj.max(n);
obj.sum(n);

obj.avg(n);
getch();
}

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