Question
Help fix in C++ thank you! /* Introduction to files This program is a variation of the previous program: LAB: Files (input and output). -
Help fix in C++ thank you!
/* Introduction to files This program is a variation of the previous program: LAB: Files (input and output).
- Generates n random numbers within a given range, displays them to the screen, and writes them to a file. - Reads the numbers from the file, displays them to the screen, and calculates the following: - number of positive numbers - number of negative numbers - numbers of 0s - average of the positive numbers - Displays all of the above to the screen. NAME: */ #include
// constants for the range of the random numbers const int MIN_R = -25; const int MAX_R = 10;
using namespace std;
int main() { ofstream outputFile; int rNum; int n; // Enter the number of random numbers to be written to a file cout > n; while ( n 20) // Input validation loop { cout > n; } // Reuse code from the previous lab // FIX ME #1 // Open an output file named "Numbers.txt". // FIX ME #2 // Write n random numbers within the range MIN_R to MAX_R to the file // FIX ME #3 // Close the output file.
cout
return 0; }
6.12 LAB: Files 2 (input and output) This program is a variation of the previous program: LAB: Files (input and output). Generates n random numbers within a given range, displays them to the screen, and writes them to a file. Reads the numbers from the file, displays them to the screen, and calculates the following: - number of positive numbers - number of negative numbers - numbers of Os-average of the positive numbers Displays all of the above to the screen as shown below: Results: 2 positive 5 negative 1 zero (s) The average of the positive numbers is: 3.5 293630.1722736Step 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