Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Need help again this week. I think I am starting to grasp this

Need help again this week. I think I am starting to grasp this. Would you add comments throughout the lab as you

do the steps? ATTACHMENT PREVIEW Download attachment// lab3: listofnumbers// <insert your name here>// read main.cpp, and follow the instructions at the bottom of main.cpp#include<iostream>usingnamespacestd;intmain(){intnumberOfElements = 0;Foat* elements =NULL;FoatuserInput;booladdingNumbersToTheList;cout<<“Keep entering numbers. Enter a non-number to stop.”<<endl;do{cin>>userInput;addingNumbersToTheList = !std::cin.fail();if(addingNumbersToTheList) {// make a bigger array to replace the old oneFoat* biggerArray =newFoat[numberOfElements+1];if(elements !=NULL){// copy the old elements into the biggerArrayfor(inti = 0; i < numberOfElements; i++){biggerArray[i] = elements[i];}// the old array is not needed anymore, we have a better copydelete []elements;}// point at the new arrayelements = biggerArray;numberOfElements = numberOfElements+1;// put the new number into the last element of the arrayelements[numberOfElements-1] = userInput;}}while(addingNumbersToTheList);// ±x cin after intentionally breaking it above.if(std::cin.fail()){std::cin.clear();while(std::cin.get() !=’\n’);}boolhasNumbers = numberOfElements > 0;if(hasNumbers) {// print the stored numberscout<<“Entered numbers: “<<endl;cout<<“{“;for(inti = 0; i < numberOfElements; ++i){if(i > 0){cout<<“, “;}cout<<elements[i];

Background image of page 1

View the Answer}cout<<“}”<<endl;foatsum = 0;For(inti = 0; i < numberOFElements; ++i){sum += elements[i];}cout<<“total: “<<sum<<endl;cout<<“average: “<<(sum / numberOFElements)<<endl;}else{cout<<“no numbers entered.”<<endl;}return0;}// INSTRUCTIONS

Background image of page 2

Show

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"