Question: PLEASE FIX MY CODE FILE IT WONT OPEN #include #include using namespace std; int main ( ) { ifstream inputfile ( Numbers . txt

PLEASE FIX MY CODE FILE IT WONT OPEN #include
#include
using namespace std;
int main()
{
ifstream inputfile("Numbers.txt");
int count =0;
int sumFirst22=0;
int sumFirst15=0;
int minVal, maxVal;
int num;
//Check whether the file exists and opened successfully
if (!inputfile.is_open())
{
cout "
Error: Can't open file or File does not exist!" endl;
return 1;
}
while (inputfile >> num){
//increment the number count
count++;
//Determine minimum and maximum value
if (count ==1){
minVal = num;
maxVal = num;
}
else {
if (num minVal)
minVal = num;
if (num > maxVal)
maxVal = num;
}
//sum first 15 and 22 numbers
if (count =15)
sumFirst15+= num;
if (count =22)
sumFirst22+= num;
}
double averageFirst22= sumFirst22/22.0;
//display output
cout "A) Count of numbers in the file: " count endl;
cout "B) Average of the first 22 numbers: " averageFirst22 endl;
cout "C) Sum of the first 15 numbers: " sumFirst15 endl;
cout "D) Minimum value found in the file: " minVal endl;
cout "E) Maximum value found in the file: " maxVal endl;
inputfile.close();
return 0;
}
#EncludeD=0=0=0 Error: Can't open file or File does not exist!
Process finished with exit code 1
 PLEASE FIX MY CODE FILE IT WONT OPEN #include #include using

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!