Download the attached CreateRandomNumbersFile.cpp file, open it in Dev C++, and then compile and run it. The program should generate a file called numbers_lastname.txt in the same folder as the program (replace lastname with your last name).
Write a program that asks for the name of an input file. Then, read all the numbers in the file, and display the following information to the screen:
The program should:
Submit the following back to this assignment (either individually or as a ZIP file):
CreateRandomNumbersFile contains the following information:
/* This program will ask the user for their last name, which will be used for
* naming an output file. The output file will consist of 500-999 random
* integers, all between 100-999.
* COSC-1436 Fundamentals of Programming I
* Author: Richard Herschede
* Date: 7/23/2019
#include <iostream> //for input/output
#include <string> //for string functions
#include <fstream> //for files
#include <cstdlib> //for rand() and srand()
#include <ctime> //for system time
using namespace std;
const int MAX_COUNT = 999; //maximum count of numbers to generate
const int MIN_COUNT = 500; //minimum count of numbers to generate
const int MAX_NUM = 999; //maximum value of random number
const int MIN_NUM = 100; //minimum value of random number
cout << "This program will generate 500-999 random numbers, and write" << endl;
cout << "them to a file. The user's last name will determine the name" << endl;
cout << "of the output file. Each random number will be between 100-999." << endl << endl;
//define local variables
ofstream outfile; //output file stream
string username, //user's last name
filename = "numbers_"; //name of output file
int num, //variable to hold random number
count; //variable to hold count of numbers
//get system time and seed random number generator
unsigned seed = time(0);
//set file name for output file
cout << "Please enter your last name: ";
filename += username + ".txt";
//open the output file (will create new or overwrite existing)
//get count of random numbers to generate
count = (rand() % (MAX_COUNT - MIN_COUNT + 1)) + MIN_COUNT;
cout << "Generating " << count << " random numbers to file " << filename << endl;
//generate random numbers and write them to output file
for (int i = 0; i < count; i++)
num = (rand() % (MAX_NUM - MIN_NUM + 1)) + MIN_NUM;
outfile << num << " ";
} //end for
//close the output file
cout << "\nProgram complete. The output file, " << filename << ", is located" << endl;
cout << "in the same directory as this program." << endl;
} //end main()
Language is C++
Keep it in the most simplest form please.
Q: Write a wholly creative quiz program that consists of three original questions that you make up acco...
A: Error in the program-Remove the points variable after each fragment of code except the point variabl...
Q: First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ...
A: Create a JAVA class of name AtmSimulator. Import DecimalFormat class to display balance up to 2 deci...
Q: The code you will need for this assignment is here (in C file) /* YOUR NAME HERE* CSCI 4100* Progr...
A: C shell is a type of command processor which enables user to write and modify commands .It can also ...
Q: Oscar has invested a huge amount of money into the stock market and doesn't trust just anyone to giv...
A: Given three variables p, m and z where p=Pain Webster, m=Meg A. Cash and z=LaZora.As per the conditi...
Q: Code needed for the following: Use the final numerical grade to look up the corresponding letter gra...
A: This C++ program obey the following rubrics: -In main method – Declaring and initializing the variab...
Q: The effects of lack of computer equipment in academic performance
A: To solve this problem .first of all you need to understand the relationship of computer devices in a...
Q: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles...
A: Program Instructions:Take car's miles/gallon and gas dollars/gallon as input using scanner class.Cal...
Q: The current deficit of Arrakis (a fictional country) is 47000000 grods (a fictional currency). It is...
A: Program Algorithm-STARTStep1: Define a class Calculate.Step2: Write the main function for the class....