Question
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug.
To be able to receive your full discussion points, you need to submit the following.
Following is your check list and rubric
Attach your .cpp file/s with an implemented bug - 20pnts
Describe what the code does in detail - 20pnts
Debug at least one other program and submit your .cpp file - 40pnts (note what the bug was in comments)
After running the debugged program, attach the screen shot of your output- 20pnts
// This program totals and averages the sales figures for any // number of days. The figures are stored in a dynamically // allocated array. #include#include using namespace std; int main() { double *sales = nullptr, // To dynamically allocate an array total = 0.0, // Accumulator average; // To hold average sales int numDays, // To hold the number of days of sales count; // Counter variable // Get the number of days of sales. cout << "How many days of sales figures do you wish "; cout << "to process? "; cin >> numDays; // Dynamically allocate an array large enough to hold // that many days of sales amounts. sales = new double[numDays]; // Get the sales figures for each day. cout << "Enter the sales figures below. "; for (count = 0; count < numDays; count++) { cout << "Day " << (count + 1) << ": "; cin >> sales[count]; } // Calculate the total sales for (count = 0; count < numDays; count++) { total += sales[count]; } // Calculate the average sales per day average = total / numDays; // Display the results cout << fixed << showpoint << setprecision(2); cout << " Total Sales: $" << total << endl; cout << "Average Sales: $" << average << endl; // Free dynamically allocated memory delete [] sales; sales = nullptr; // Make sales a nullptr. return 0; }
Above is the code that needs to be bugged. This should be in C++. I have been using Xcode to put these codes into.
Thank you in advance.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started