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

Write, compile, and run a C++ program that stores the following numbers in an ar

ID: 3646412 • Letter: W

Question

Write, compile, and run a C++ program that stores the following numbers in an
array named prices: 9.92, 6.32, 12.63, 5.95, and 10.29. Your program should also create two
arrays named units and amounts, each capable of storing five double-precision numbers.
Using a for loop and a cin statement, have your program accept five user-input numbers in
the units array when the program is run. Your program should store the product of the corresponding
values in the prices and units array in the amounts array. For example, use
amounts[1]

Explanation / Answer

#include
int main()

{

double total=0;

double fprices[]={9.92, 6.32, 12.63, 5.95,10.29};

int i;

double funits[5],amountsf[5];

cout<<"Please enter no.of units"<<endl;

for(i=0;i<5;i++)

cin>>funits[i];

for(i=0;i<5;i++) //computing the product values

amountsf[i]=fprices[i]*funits[i];

cout<<"Price Units Amount "<<endl;

for(i=0;i<5;i++)

cout<<" "<<fprices[i]<<" "<<" "<<funits[i]<<" "<<" "<<amounts[i]<<endl;

for(i=0;i<5;i++)

total=total+amount[i];

cout<<"total amount:"<<total;

return 0;

}